-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Update the ways to get a pointer from a box in std::ptr docs #23312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
//! types are the same size. Because `Box<T>` and `*mut T` have the same | ||
//! representation they can be trivially, | ||
//! though unsafely, transformed from one type to the other. | ||
//! The `into_raw` function consumes an onwed box and returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just 'box' not 'owned box'
r=me after some nits |
Fixed the typos. |
There's "owned box" in the subsection title. Not sure if "owned" should be removed there too |
Yes, it should be, that term isn't used anymore. |
Show how to get a pointer without destroying the box. Use `boxed::into_raw` instead of `mem::transmute`.
Done! |
@bors: r+ rollup |
Show how to get a pointer without destroying the box. Use `boxed::into_raw` instead of `mem::transmute`. I removed the `let my_num: *const i32 = mem::transmute(my_num);` case altogether because we own the box, a `*mut` pointer is good anywhere a `*const` is needed, `from_raw` takes a mutable pointer and casting from a `*const` caused an ICE.
@gkoz: ICE? Did you file that? |
Show how to get a pointer without destroying the box.
Use
boxed::into_raw
instead ofmem::transmute
.I removed the
let my_num: *const i32 = mem::transmute(my_num);
case altogether because we own the box, a*mut
pointer is good anywhere a*const
is needed,from_raw
takes a mutable pointer and casting from a*const
caused an ICE.