Yes, you lose the ability to deallocate individual nodes. Pretty hard to
express in a type system. Still I wish I could at least have the compiler
help me to ensure my unsafe pointers never escape the lifetime of the
container; right now I must trust the programmer (and in my case, the
container basically lives as long as the program, anyway).

Slots sound nice. Is the idea that one would do Rc<T> for read-only access
and Rc<Slot<T>> for mutable access? How does this protect against multiple
mutations "at once"?

On Tue, Nov 12, 2013 at 3:13 PM, Patrick Walton <[email protected]>wrote:

>
>> In performance-critical code I sometimes give up and just have an array
>> of ~T and use an unsafe ptr to T in all my other references... which is
>> OK as long as these only live as long as the container, but I get zero
>> compiler support for that. I wish there was a way to say "this borrowed
>> pointer lives only as long as its container". That doesn't seem to be in
>> the cards though :-(
>>
>
> I don't know how to make that sound, unfortunately, other than using an
> arena and allocating all the nodes into it (losing the ability to
> deallocate individual nodes).
>
> Patrick
>
>
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to