@@ -671,10 +671,25 @@ impl<T> [T] {
671
671
/// # Examples
672
672
///
673
673
/// ```
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
+ /// }
678
693
/// ```
679
694
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
680
695
#[ inline]
@@ -695,26 +710,16 @@ impl<T> [T] {
695
710
/// # Examples
696
711
///
697
712
/// ```
698
- /// let mut v = [1, 2, 3, 4, 5, 6];
699
- ///
713
+ /// let mut v = [1, 0, 3, 0, 5, 6];
700
714
/// // scoped to restrict the lifetime of the borrows
701
715
/// {
702
- /// let (left, right) = v.split_at_mut(0);
703
- /// assert!(left == []);
704
- /// assert!(right == [1, 2, 3, 4, 5, 6]);
705
- /// }
706
- ///
707
- /// {
708
716
/// 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;
717
721
/// }
722
+ /// assert!(v == [1, 2, 3, 4, 5, 6]);
718
723
/// ```
719
724
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
720
725
#[ inline]
0 commit comments