Skip to content

Commit c0bee60

Browse files
committed
Make it nicer from @alexandermerritt
1 parent 97003e5 commit c0bee60

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/libcore/intrinsics.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ extern "rust-intrinsic" {
339339
/// # Alternatives
340340
///
341341
/// 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
345343
/// 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`:
347347
///
348348
/// Turning a pointer into a `usize`:
349349
///
@@ -374,7 +374,8 @@ extern "rust-intrinsic" {
374374
/// let val_transmuted = unsafe {
375375
/// std::mem::transmute::<&mut i32, &mut u32>(ptr)
376376
/// };
377-
/// // Now, put together `as` and reborrowing
377+
/// // Now, put together `as` and reborrowing - note the chaining of `as`
378+
/// // `as` is not transitive
378379
/// let val_casts = unsafe { &mut *(ptr as *mut i32 as *mut u32) };
379380
/// ```
380381
///

0 commit comments

Comments
 (0)