in rust how do things like Box::new and Vec::new allocate/move their contents to the heap
-
Show this thread
-
I'm imagining that, unlike C, there's little need in rust to invent your own structures as std has so much in it, I'm just curious
1 reply 0 retweets 1 likeShow this thread -
also in C you explicitly allocate on the heap, whereas in rust is feels like everything is on the stack except smart pointer types (Box, Rc, Vec, String, etc) magically put their contents on the heap
3 replies 0 retweets 3 likesShow this thread -
Replying to @mountain_ghosts
*inner_raw_pointer = value In release builds the copy will be optimized away, allocating on the heap directly instead of memcpying a stack value
1 reply 0 retweets 2 likes
Replying to @sgrif @mountain_ghosts
The pointer will come from malloc, same as in C. You can customize the allocator used with the #[global_allocator] attribute
6:38 AM - 31 Mar 2019
0 replies
0 retweets
2 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.