Skip to content

Update the ways to get a pointer from a box in std::ptr docs#23312

Merged
bors merged 1 commit into
rust-lang:masterfrom
gkoz:ptr_from_box_docs
Mar 13, 2015
Merged

Update the ways to get a pointer from a box in std::ptr docs#23312
bors merged 1 commit into
rust-lang:masterfrom
gkoz:ptr_from_box_docs

Conversation

@gkoz

@gkoz gkoz commented Mar 12, 2015

Copy link
Copy Markdown
Contributor

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

gkoz commented Mar 12, 2015

Copy link
Copy Markdown
Contributor Author

r? @steveklabnik

@rust-highfive rust-highfive assigned steveklabnik and unassigned huonw Mar 12, 2015
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@gkoz

gkoz commented Mar 12, 2015

Copy link
Copy Markdown
Contributor Author

r? @steveklabnik

Comment thread src/libcore/ptr.rs Outdated

Copy link
Copy Markdown
Contributor

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'

@steveklabnik

Copy link
Copy Markdown
Contributor

r=me after some nits

@gkoz

gkoz commented Mar 12, 2015

Copy link
Copy Markdown
Contributor Author

Fixed the typos.

@gkoz

gkoz commented Mar 12, 2015

Copy link
Copy Markdown
Contributor Author

There's "owned box" in the subsection title. Not sure if "owned" should be removed there too

@steveklabnik

Copy link
Copy Markdown
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`.
@gkoz

gkoz commented Mar 12, 2015

Copy link
Copy Markdown
Contributor Author

Done!

@steveklabnik

Copy link
Copy Markdown
Contributor

@bors: r+ rollup

@bors

bors commented Mar 12, 2015

Copy link
Copy Markdown
Collaborator

@bors r=steveklabnik 5d9ed0b

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.
@bors bors merged commit 5d9ed0b into rust-lang:master Mar 13, 2015
@Ms2ger

Ms2ger commented Mar 14, 2015

Copy link
Copy Markdown
Contributor

@gkoz: ICE? Did you file that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants