Update the ways to get a pointer from a box in std::ptr docs#23312
Merged
bors merged 1 commit intorust-lang:masterfrom Mar 13, 2015
gkoz:ptr_from_box_docs
Merged
Update the ways to get a pointer from a box in std::ptr docs#23312bors merged 1 commit intorust-lang:masterfrom gkoz:ptr_from_box_docs
bors merged 1 commit intorust-lang:masterfrom
gkoz:ptr_from_box_docs
Conversation
Contributor
Author
Contributor
|
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
Contributor
Author
src/libcore/ptr.rs
Outdated
Contributor
There was a problem hiding this comment.
just 'box' not 'owned box'
Contributor
|
r=me after some nits |
Contributor
Author
|
Fixed the typos. |
Contributor
Author
|
There's "owned box" in the subsection title. Not sure if "owned" should be removed there too |
Contributor
|
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`.
Contributor
Author
|
Done! |
Contributor
|
@bors: r+ rollup |
Collaborator
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Mar 13, 2015
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.
Contributor
|
@gkoz: ICE? Did you file that? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Show how to get a pointer without destroying the box.
Use
boxed::into_rawinstead ofmem::transmute.I removed the
let my_num: *const i32 = mem::transmute(my_num);case altogether because we own the box, a*mutpointer is good anywhere a*constis needed,from_rawtakes a mutable pointer and casting from a*constcaused an ICE.