@@ -278,32 +278,21 @@ extern "rust-intrinsic" {
278
278
/// Moves a value out of scope without running drop glue.
279
279
pub fn forget < T > ( _: T ) -> ( ) ;
280
280
281
- /// Reinterprets the bits of a value of one type as another type. Both types
281
+ /// Reinterprets the bits of a value of one type as another type; both types
282
282
/// must have the same size. Neither the original, nor the result, may be an
283
- /// [invalid value]
284
- /// (https://doc.rust-lang.org/nomicon/meet-safe-and-unsafe.html).
283
+ /// [invalid value] (../../nomicon/meet-safe-and-unsafe.html).
285
284
///
286
- /// `transmute` is semantically equivalent to the following:
287
- ///
288
- /// ```
289
- /// use std::{mem, ptr};
290
- /// // assuming that T and U are the same size
291
- /// unsafe fn transmute<T, U>(t: T) -> U {
292
- /// let mut u: U = mem::uninitialized();
293
- /// ptr::copy_nonoverlapping(&t as *const T as *const u8,
294
- /// &mut u as *mut U as *mut u8,
295
- /// mem::size_of::<T>());
296
- /// mem::forget(t);
297
- /// u
298
- /// }
299
- /// ```
285
+ /// `transmute` is semantically equivalent to a bitwise move of one type
286
+ /// into another. It copies the bits from the destination type into the
287
+ /// source type, then forgets the original. If you know C or C++, it's like
288
+ /// `memcpy` under the hood.
300
289
///
301
290
/// `transmute` is incredibly unsafe. There are a vast number of ways to
302
291
/// cause undefined behavior with this function. `transmute` should be
303
292
/// the absolute last resort.
304
293
///
305
- /// The [nomicon](https://doc.rust-lang.org /nomicon/transmutes.html) has
306
- /// additional documentation.
294
+ /// The [nomicon](../.. /nomicon/transmutes.html) has additional
295
+ /// documentation.
307
296
///
308
297
/// # Alternatives
309
298
///
0 commit comments