Skip to content

book: Change raw pointer conversion example #29105

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

Merged
merged 1 commit into from
Oct 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/doc/trpl/raw-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,15 @@ these properties are true for any references, no matter how they are created,
and so any conversion from raw pointers is asserting that they hold. The
programmer *must* guarantee this.

The recommended method for the conversion is
The recommended method for the conversion is:

```rust
let i: u32 = 1;

// explicit cast
let i: u32 = 1;
let p_imm: *const u32 = &i as *const u32;
let mut m: u32 = 2;

// implicit coercion
let mut m: u32 = 2;
let p_mut: *mut u32 = &mut m;

unsafe {
Expand Down