@@ -337,7 +337,7 @@ pub unsafe fn zeroed<T>() -> T {
337
337
/// Bypasses Rust's normal memory-initialization checks by pretending to
338
338
/// produce a value of type `T`, while doing nothing at all.
339
339
///
340
- /// **This is incredibly dangerous, and should not be done lightly. Deeply
340
+ /// **This is incredibly dangerous and should not be done lightly. Deeply
341
341
/// consider initializing your memory with a default value instead.**
342
342
///
343
343
/// This is useful for [FFI] functions and initializing arrays sometimes,
@@ -352,24 +352,18 @@ pub unsafe fn zeroed<T>() -> T {
352
352
/// a boolean, your program may take one, both, or neither of the branches.
353
353
///
354
354
/// 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
356
356
/// value and its fields if you try to overwrite it in a normal manner. The only way
357
357
/// to safely initialize an uninitialized value is with [`ptr::write`][write],
358
358
/// [`ptr::copy`][copy], or [`ptr::copy_nonoverlapping`][copy_no].
359
359
///
360
- /// If the value does implement `Drop`, it must be initialized before
360
+ /// If the value does implement [ `Drop`] , it must be initialized before
361
361
/// it goes out of scope (and therefore would be dropped). Note that this
362
362
/// includes a `panic` occurring and unwinding the stack suddenly.
363
363
///
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
- ///
370
364
/// # Examples
371
365
///
372
- /// Here's how to safely initialize an array of `Vec`s.
366
+ /// Here's how to safely initialize an array of [ `Vec`] s.
373
367
///
374
368
/// ```
375
369
/// use std::mem;
@@ -410,15 +404,24 @@ pub unsafe fn zeroed<T>() -> T {
410
404
/// ```
411
405
///
412
406
/// 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
415
409
/// vastly less dangerous, as long as you can live with an extra heap
416
410
/// allocation:
417
411
///
418
412
/// ```
419
413
/// let data: Vec<Vec<u32>> = vec![Vec::new(); 1000];
420
414
/// println!("{:?}", &data[0]);
421
415
/// ```
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
422
425
#[ inline]
423
426
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
424
427
pub unsafe fn uninitialized < T > ( ) -> T {
@@ -492,7 +495,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
492
495
/// }
493
496
/// ```
494
497
///
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
496
499
/// `self.buf`. But `replace` can be used to disassociate the original value of `self.buf` from
497
500
/// `self`, allowing it to be returned:
498
501
///
@@ -507,6 +510,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
507
510
/// }
508
511
/// }
509
512
/// ```
513
+ ///
514
+ /// [`Clone`]: ../../std/clone/trait.Clone.html
510
515
#[ inline]
511
516
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
512
517
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 {
571
576
/// v.push(4); // no problems
572
577
/// ```
573
578
///
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:
576
581
///
577
582
/// ```
578
583
/// use std::cell::RefCell;
@@ -588,7 +593,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
588
593
/// println!("{}", *borrow);
589
594
/// ```
590
595
///
591
- /// Integers and other types implementing `Copy` are unaffected by `drop`.
596
+ /// Integers and other types implementing [ `Copy`] are unaffected by `drop`.
592
597
///
593
598
/// ```
594
599
/// #[derive(Copy, Clone)]
@@ -602,6 +607,8 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
602
607
/// println!("x: {}, y: {}", x, y.0); // still available
603
608
/// ```
604
609
///
610
+ /// [`RefCell`]: ../../std/cell/struct.RefCell.html
611
+ /// [`Copy`]: ../../std/marker/trait.Copy.html
605
612
#[ inline]
606
613
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
607
614
pub fn drop < T > ( _x : T ) { }
0 commit comments