Skip to content

Commit

Permalink
Fix some other small nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ubsan committed Jul 2, 2016
1 parent 233b45f commit 6928bbb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libcore/intrinsics.rs
Expand Up @@ -316,7 +316,7 @@ extern "rust-intrinsic" {
/// // turning a pointer into a usize
/// let ptr = &0;
/// let ptr_num_transmute = std::mem::transmute::<&i32, usize>(ptr);
/// // now with more `as`
/// // Use `as` casts instead
/// let ptr_num_cast = ptr as *const i32 as usize;
///
///
Expand All @@ -330,15 +330,15 @@ extern "rust-intrinsic" {
/// // Turning an &mut T into an &mut U
/// let ptr = &mut 0;
/// let val_transmuted = std::mem::transmute::<&mut i32, &mut u32>(ptr);
/// // Reborrowing continues to play a role here, but now we add `as` casts
/// // Now let's put together `as` and reborrowing
/// let val_casts = &mut *(ptr as *mut i32 as *mut u32);
///
///
/// // Turning an `&str` into an `&[u8]`
/// // this is not a good way to do this.
/// let slice = unsafe { mem::transmute::<&str, &[u8]>("Rust") };
/// assert_eq!(slice, [82, 117, 115, 116]);
/// // this is not a good way to do this.
/// // use .as_bytes()
/// // You could use `str::as_bytes`
/// let slice = "Rust".as_bytes();
/// assert_eq!(slice, [82, 117, 115, 116]);
/// // Or, just use a byte string, if you have control over the string
Expand Down

0 comments on commit 6928bbb

Please sign in to comment.