|
Jsor posted:E: Actually, on a mostly unrelated note, can someone explain Box to me? I mean, I know what it does. It's a lot like a malloc'd pointer in C. I just can never find a place to use it because every time I try it feels like the Box type ends up infecting the return stack of the entire program. The only use case I've found that requires a Box is doing direct recursive relationships. http://is.gd/z1z4yB You'd also want to wrap big data structures in a Box, the stack you're given is probably around 2MB. So stuff like images, or if you're doing data visualisation, you'll probably have a huge dataset, which would probably cause a stack overflow.
|
# ¿ Feb 21, 2016 22:36 |
|
|
# ¿ May 3, 2024 01:06 |
|
FamDav posted:super confused; why does .iter() doesn't consume the collection it is based on, which is why it gives references. So you can have the Iterator, and the collection. If don't want the collection anymore, you can call .into_iter(), which will take the collection, and convert it into an Iterator. The reason the map works where you dereference x, is because i32 has the trait Copy, so when you dereference it, you're implicitly cloning the value. Neither one of these will compile with a non Copyable type such as a String. Aaronepower fucked around with this message at 02:07 on Feb 22, 2016 |
# ¿ Feb 22, 2016 02:04 |