Skip to content

Commit 451af79

Browse files
committed
Fix links, change example to english
1 parent 15a49fe commit 451af79

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/libcore/intrinsics.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -278,32 +278,21 @@ extern "rust-intrinsic" {
278278
/// Moves a value out of scope without running drop glue.
279279
pub fn forget<T>(_: T) -> ();
280280

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
282282
/// 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).
285284
///
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.
300289
///
301290
/// `transmute` is incredibly unsafe. There are a vast number of ways to
302291
/// cause undefined behavior with this function. `transmute` should be
303292
/// the absolute last resort.
304293
///
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.
307296
///
308297
/// # Alternatives
309298
///

0 commit comments

Comments
 (0)