@@ -671,10 +671,25 @@ impl<T> [T] {
671671 /// # Examples
672672 ///
673673 /// ```
674- /// let v = [10, 40, 30, 20, 50];
675- /// let (v1, v2) = v.split_at(2);
676- /// assert_eq!([10, 40], v1);
677- /// assert_eq!([30, 20, 50], v2);
674+ /// let v = [1, 2, 3, 4, 5, 6];
675+ ///
676+ /// {
677+ /// let (left, right) = v.split_at(0);
678+ /// assert!(left == []);
679+ /// assert!(right == [1, 2, 3, 4, 5, 6]);
680+ /// }
681+ ///
682+ /// {
683+ /// let (left, right) = v.split_at(2);
684+ /// assert!(left == [1, 2]);
685+ /// assert!(right == [3, 4, 5, 6]);
686+ /// }
687+ ///
688+ /// {
689+ /// let (left, right) = v.split_at(6);
690+ /// assert!(left == [1, 2, 3, 4, 5, 6]);
691+ /// assert!(right == []);
692+ /// }
678693 /// ```
679694 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
680695 #[ inline]
@@ -695,26 +710,16 @@ impl<T> [T] {
695710 /// # Examples
696711 ///
697712 /// ```
698- /// let mut v = [1, 2, 3, 4, 5, 6];
699- ///
713+ /// let mut v = [1, 0, 3, 0, 5, 6];
700714 /// // scoped to restrict the lifetime of the borrows
701715 /// {
702- /// let (left, right) = v.split_at_mut(0);
703- /// assert!(left == []);
704- /// assert!(right == [1, 2, 3, 4, 5, 6]);
705- /// }
706- ///
707- /// {
708716 /// let (left, right) = v.split_at_mut(2);
709- /// assert!(left == [1, 2]);
710- /// assert!(right == [3, 4, 5, 6]);
711- /// }
712- ///
713- /// {
714- /// let (left, right) = v.split_at_mut(6);
715- /// assert!(left == [1, 2, 3, 4, 5, 6]);
716- /// assert!(right == []);
717+ /// assert!(left == [1, 0]);
718+ /// assert!(right == [3, 0, 5, 6]);
719+ /// left[1] = 2;
720+ /// right[1] = 4;
717721 /// }
722+ /// assert!(v == [1, 2, 3, 4, 5, 6]);
718723 /// ```
719724 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
720725 #[ inline]
0 commit comments