@@ -316,7 +316,7 @@ extern "rust-intrinsic" {
316
316
/// // turning a pointer into a usize
317
317
/// let ptr = &0;
318
318
/// let ptr_num_transmute = std::mem::transmute::<&i32, usize>(ptr);
319
- /// // now with more `as`
319
+ /// // Use `as` casts instead
320
320
/// let ptr_num_cast = ptr as *const i32 as usize;
321
321
///
322
322
///
@@ -330,15 +330,15 @@ extern "rust-intrinsic" {
330
330
/// // Turning an &mut T into an &mut U
331
331
/// let ptr = &mut 0;
332
332
/// let val_transmuted = std::mem::transmute::<&mut i32, &mut u32>(ptr);
333
- /// // Reborrowing continues to play a role here, but now we add `as` casts
333
+ /// // Now let's put together `as` and reborrowing
334
334
/// let val_casts = &mut *(ptr as *mut i32 as *mut u32);
335
335
///
336
336
///
337
337
/// // Turning an `&str` into an `&[u8]`
338
+ /// // this is not a good way to do this.
338
339
/// let slice = unsafe { mem::transmute::<&str, &[u8]>("Rust") };
339
340
/// assert_eq!(slice, [82, 117, 115, 116]);
340
- /// // this is not a good way to do this.
341
- /// // use .as_bytes()
341
+ /// // You could use `str::as_bytes`
342
342
/// let slice = "Rust".as_bytes();
343
343
/// assert_eq!(slice, [82, 117, 115, 116]);
344
344
/// // Or, just use a byte string, if you have control over the string
0 commit comments