Let me ask another way:  what's wrong with thinking of ~ just as meaning
"allocate to the heap and subject to move semantics"?  When would that
simplification bite me in the ass regarding owned boxes vs strs/vecs?

I get that I should very rarely want that for things that aren't dynamic
containers or recursive data structures.  But beyond that, am I ever going
to get myself in trouble not remembering the details of the difference
between how ~T works vs ~[T]?


On Thursday, November 7, 2013, Daniel Micay wrote:

> On Thu, Nov 7, 2013 at 7:49 PM, Jason Fager <jfa...@gmail.com> wrote:
>
>> Can you speak a little to the practical differences between owned boxes
>> and ~[T]/~str?  How does the difference affect how I should use each?
>
>
> I wrote the section on owned boxes in the tutorial currently in master, so
> I would suggest reading that. It's very rare for there to be a use case for
> an owned box outside of a recursive data structure or plugin system (traits
> as objects).
>
> The coverage in the tutorial of vectors/strings is not only lacking in
> depth but is also *incorrect*, so I understand why there's a lot of
> confusion about them.
>
> Vectors/strings are containers, and aren't connected to owned boxes any
> more than HashMap/TreeMap/TrieMap. I would prefer it if the syntactic sugar
> didn't exist and we just had generic container literals, because it seems
> to end up causing a lot of confusion.
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to