File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -339,11 +339,11 @@ extern "rust-intrinsic" {
339
339
/// # Alternatives
340
340
///
341
341
/// However, many uses of `transmute` can be achieved through other means.
342
- /// This is unfortunate because either `transmute` isn't guaranteed to work
343
- /// in that case, and only does because of rustc's current implemenation;
344
- /// or, more commonly, `transmute` is just too powerful. It can transform
342
+ /// `transmute` can transform
345
343
/// any type into any other, with just the caveat that they're the same
346
- /// size. Some more or less common uses, and a better way, are as follows:
344
+ /// size, and it sometimes results in interesting results. Below are common
345
+ /// applications of `transmute` which can be replaced with safe applications
346
+ /// of `as`:
347
347
///
348
348
/// Turning a pointer into a `usize`:
349
349
///
@@ -374,7 +374,8 @@ extern "rust-intrinsic" {
374
374
/// let val_transmuted = unsafe {
375
375
/// std::mem::transmute::<&mut i32, &mut u32>(ptr)
376
376
/// };
377
- /// // Now, put together `as` and reborrowing
377
+ /// // Now, put together `as` and reborrowing - note the chaining of `as`
378
+ /// // `as` is not transitive
378
379
/// let val_casts = unsafe { &mut *(ptr as *mut i32 as *mut u32) };
379
380
/// ```
380
381
///
You can’t perform that action at this time.
0 commit comments