@@ -670,6 +670,9 @@ pub unsafe fn uninitialized<T>() -> T {
670
670
671
671
/// Swaps the values at two mutable locations, without deinitializing either one.
672
672
///
673
+ /// * If you want to swap with a default or dummy value, see [`take`].
674
+ /// * If you want to swap with a passed value, returning the old value, see [`replace`].
675
+ ///
673
676
/// # Examples
674
677
///
675
678
/// ```
@@ -683,6 +686,9 @@ pub unsafe fn uninitialized<T>() -> T {
683
686
/// assert_eq!(42, x);
684
687
/// assert_eq!(5, y);
685
688
/// ```
689
+ ///
690
+ /// [`replace`]: fn.replace.html
691
+ /// [`take`]: fn.take.html
686
692
#[ inline]
687
693
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
688
694
pub fn swap < T > ( x : & mut T , y : & mut T ) {
@@ -695,6 +701,9 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
695
701
696
702
/// Replaces `dest` with the default value of `T`, returning the previous `dest` value.
697
703
///
704
+ /// * If you want to replace the values of two variables, see [`swap`].
705
+ /// * If you want to replace with a passed value instead of the default value, see [`replace`].
706
+ ///
698
707
/// # Examples
699
708
///
700
709
/// A simple example:
@@ -747,6 +756,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
747
756
/// ```
748
757
///
749
758
/// [`Clone`]: ../../std/clone/trait.Clone.html
759
+ /// [`replace`]: fn.replace.html
760
+ /// [`swap`]: fn.swap.html
750
761
#[ inline]
751
762
#[ stable( feature = "mem_take" , since = "1.40.0" ) ]
752
763
pub fn take < T : Default > ( dest : & mut T ) -> T {
@@ -757,6 +768,9 @@ pub fn take<T: Default>(dest: &mut T) -> T {
757
768
///
758
769
/// Neither value is dropped.
759
770
///
771
+ /// * If you want to replace the values of two variables, see [`swap`].
772
+ /// * If you want to replace with a default value, see [`take`].
773
+ ///
760
774
/// # Examples
761
775
///
762
776
/// A simple example:
@@ -810,6 +824,8 @@ pub fn take<T: Default>(dest: &mut T) -> T {
810
824
/// ```
811
825
///
812
826
/// [`Clone`]: ../../std/clone/trait.Clone.html
827
+ /// [`swap`]: fn.swap.html
828
+ /// [`take`]: fn.take.html
813
829
#[ inline]
814
830
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
815
831
#[ must_use = "if you don't need the old value, you can just assign the new value directly" ]
0 commit comments