Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to definition of P<T> type to Appendix D: Code Index #182

Closed
alexreg opened this issue Aug 14, 2018 · 6 comments · Fixed by #275
Closed

Add to definition of P<T> type to Appendix D: Code Index #182

alexreg opened this issue Aug 14, 2018 · 6 comments · Fixed by #275
Labels
Easy Might be a good place for a beginner

Comments

@alexreg
Copy link
Contributor

alexreg commented Aug 14, 2018

And why it's needed.

@mark-i-m mark-i-m mentioned this issue Aug 20, 2018
15 tasks
@mark-i-m mark-i-m added help wanted Extra attention is needed Medium Might require some prior knowledge or code reading labels Aug 20, 2018
@alexreg
Copy link
Contributor Author

alexreg commented Aug 20, 2018

@eddyb's definition of it is an "immutable Box<T>". I suppose it's needed just due to the nature of tree data structures?

@eddyb
Copy link
Member

eddyb commented Aug 20, 2018

It's not "needed", not to a large extent. The actual code has (potentially-outdated) documentation.

@alexreg
Copy link
Contributor Author

alexreg commented Aug 20, 2018

@eddyb Well, heap allocation is surely needed, otherwise we'd have to deal with an immutable tree, and that would be very expensive during construction and later modification.

@eddyb
Copy link
Member

eddyb commented Aug 21, 2018

I mean as a separate concept from Box or anything else.

@mark-i-m
Copy link
Member

Sorry, I'm not sure I understand. We use P when we need an owned immutable pointer. We can't use &T because that is not owned and we can't use Box because it is not immutable. Is that correct?

@alexreg
Copy link
Contributor Author

alexreg commented Aug 21, 2018

@eddyb Right, fair.

@mark-i-m More or less, yes... @eddyb is saying that P<> doesn't really provide anything new over Box<> though – it's just a new-type with a immutability guarantee.

@mark-i-m mark-i-m added Easy Might be a good place for a beginner and removed Medium Might require some prior knowledge or code reading labels Aug 21, 2018
mark-i-m added a commit to mark-i-m/rustc-guide that referenced this issue Jan 24, 2019
@mark-i-m mark-i-m removed the help wanted Extra attention is needed label Jan 24, 2019
mark-i-m added a commit that referenced this issue Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Might be a good place for a beginner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants