You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add to definition of P<T> type to Appendix D: Code Index #182
@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.
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?
@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.
Activity
alexreg commentedon 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 commentedon Aug 20, 2018
It's not "needed", not to a large extent. The actual code has (potentially-outdated) documentation.
alexreg commentedon 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 commentedon Aug 21, 2018
I mean as a separate concept from Box or anything else.
mark-i-m commentedon Aug 21, 2018
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 commentedon Aug 21, 2018
@eddyb Right, fair.
@mark-i-m More or less, yes... @eddyb is saying that
P<>doesn't really provide anything new overBox<>though – it's just a new-type with a immutability guarantee.fix rust-lang#182
fix #182