Skip to content

Commit bfdf652

Browse files
Add missing urls for mem module
1 parent 280362a commit bfdf652

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/libcore/mem.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ pub unsafe fn zeroed<T>() -> T {
337337
/// Bypasses Rust's normal memory-initialization checks by pretending to
338338
/// produce a value of type `T`, while doing nothing at all.
339339
///
340-
/// **This is incredibly dangerous, and should not be done lightly. Deeply
340+
/// **This is incredibly dangerous and should not be done lightly. Deeply
341341
/// consider initializing your memory with a default value instead.**
342342
///
343343
/// This is useful for [FFI] functions and initializing arrays sometimes,
@@ -352,24 +352,18 @@ pub unsafe fn zeroed<T>() -> T {
352352
/// a boolean, your program may take one, both, or neither of the branches.
353353
///
354354
/// Writing to the uninitialized value is similarly dangerous. Rust believes the
355-
/// value is initialized, and will therefore try to [`Drop`][drop] the uninitialized
355+
/// value is initialized, and will therefore try to [`Drop`] the uninitialized
356356
/// value and its fields if you try to overwrite it in a normal manner. The only way
357357
/// to safely initialize an uninitialized value is with [`ptr::write`][write],
358358
/// [`ptr::copy`][copy], or [`ptr::copy_nonoverlapping`][copy_no].
359359
///
360-
/// If the value does implement `Drop`, it must be initialized before
360+
/// If the value does implement [`Drop`], it must be initialized before
361361
/// it goes out of scope (and therefore would be dropped). Note that this
362362
/// includes a `panic` occurring and unwinding the stack suddenly.
363363
///
364-
/// [ub]: ../../reference.html#behavior-considered-undefined
365-
/// [write]: ../ptr/fn.write.html
366-
/// [copy]: ../intrinsics/fn.copy.html
367-
/// [copy_no]: ../intrinsics/fn.copy_nonoverlapping.html
368-
/// [drop]: ../ops/trait.Drop.html
369-
///
370364
/// # Examples
371365
///
372-
/// Here's how to safely initialize an array of `Vec`s.
366+
/// Here's how to safely initialize an array of [`Vec`]s.
373367
///
374368
/// ```
375369
/// use std::mem;
@@ -410,15 +404,24 @@ pub unsafe fn zeroed<T>() -> T {
410404
/// ```
411405
///
412406
/// This example emphasizes exactly how delicate and dangerous using `mem::uninitialized`
413-
/// can be. Note that the `vec!` macro *does* let you initialize every element with a
414-
/// value that is only `Clone`, so the following is semantically equivalent and
407+
/// can be. Note that the [`vec!`] macro *does* let you initialize every element with a
408+
/// value that is only [`Clone`], so the following is semantically equivalent and
415409
/// vastly less dangerous, as long as you can live with an extra heap
416410
/// allocation:
417411
///
418412
/// ```
419413
/// let data: Vec<Vec<u32>> = vec![Vec::new(); 1000];
420414
/// println!("{:?}", &data[0]);
421415
/// ```
416+
///
417+
/// [`Vec`]: ../../std/vec/struct.Vec.html
418+
/// [`vec!`]: ../../std/macro.vec.html
419+
/// [`Clone`]: ../../std/clone/trait.Clone.html
420+
/// [ub]: ../../reference.html#behavior-considered-undefined
421+
/// [write]: ../ptr/fn.write.html
422+
/// [copy]: ../intrinsics/fn.copy.html
423+
/// [copy_no]: ../intrinsics/fn.copy_nonoverlapping.html
424+
/// [`Drop`]: ../ops/trait.Drop.html
422425
#[inline]
423426
#[stable(feature = "rust1", since = "1.0.0")]
424427
pub unsafe fn uninitialized<T>() -> T {
@@ -492,7 +495,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
492495
/// }
493496
/// ```
494497
///
495-
/// Note that `T` does not necessarily implement `Clone`, so it can't even clone and reset
498+
/// Note that `T` does not necessarily implement [`Clone`], so it can't even clone and reset
496499
/// `self.buf`. But `replace` can be used to disassociate the original value of `self.buf` from
497500
/// `self`, allowing it to be returned:
498501
///
@@ -507,6 +510,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
507510
/// }
508511
/// }
509512
/// ```
513+
///
514+
/// [`Clone`]: ../../std/clone/trait.Clone.html
510515
#[inline]
511516
#[stable(feature = "rust1", since = "1.0.0")]
512517
pub fn replace<T>(dest: &mut T, mut src: T) -> T {
@@ -571,8 +576,8 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
571576
/// v.push(4); // no problems
572577
/// ```
573578
///
574-
/// Since `RefCell` enforces the borrow rules at runtime, `drop` can
575-
/// release a `RefCell` borrow:
579+
/// Since [`RefCell`] enforces the borrow rules at runtime, `drop` can
580+
/// release a [`RefCell`] borrow:
576581
///
577582
/// ```
578583
/// use std::cell::RefCell;
@@ -588,7 +593,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
588593
/// println!("{}", *borrow);
589594
/// ```
590595
///
591-
/// Integers and other types implementing `Copy` are unaffected by `drop`.
596+
/// Integers and other types implementing [`Copy`] are unaffected by `drop`.
592597
///
593598
/// ```
594599
/// #[derive(Copy, Clone)]
@@ -602,6 +607,8 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
602607
/// println!("x: {}, y: {}", x, y.0); // still available
603608
/// ```
604609
///
610+
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
611+
/// [`Copy`]: ../../std/marker/trait.Copy.html
605612
#[inline]
606613
#[stable(feature = "rust1", since = "1.0.0")]
607614
pub fn drop<T>(_x: T) { }

0 commit comments

Comments
 (0)