Can someone explain to me how `Box::from_raw` and `Box::into_raw` are able to work with unsized types? Aren't we 100% for sure loosing the size/vtable? /cc @Gankro
-
-
-
Replying to @Gankra_
So you're saying `mem::size_of::<*const [u8]>` is double width, right? Shouldn't the compiler be disallowing a cast from a fat raw pointer to a thin raw pointer? If `Box::<[u8]>::into_raw` goes through C, that will cause big problems right?
2 replies 0 retweets 0 likes -
Replying to @sgrif
Not being able to cast from a slice to a c-array would kinda blow? Box<[T]> barely exists so not much thought is put into it.
1 reply 0 retweets 1 like -
Replying to @Gankra_
Isn't `slice.as_ptr()` around for that exact purpose?
1 reply 0 retweets 0 likes -
-
Replying to @Gankra_
ptr.as_ref().map(|s| s.as_ptr()).unwrap_or_else(ptr::null)
1 reply 0 retweets 0 likes -
No but seriously there is absolutely no way Box::into_raw could be used on an insized type without leaking memory or causing UB (most likely the latter because nothing complains at all about this or gives any indication you are shooting yourself in the foot)
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.