@@ -535,6 +535,16 @@ fn slice_index_order_fail(index: usize, end: usize) -> ! {
535535
536536// FIXME implement indexing with inclusive ranges
537537
538+ /// Implements slicing with syntax `&self[begin .. end]`.
539+ ///
540+ /// Returns a slice of self for the index range [`begin`..`end`).
541+ ///
542+ /// This operation is `O(1)`.
543+ ///
544+ /// # Panics
545+ ///
546+ /// Requires that `begin <= end` and `end <= self.len()`,
547+ /// otherwise slicing will panic.
538548#[ stable( feature = "rust1" , since = "1.0.0" ) ]
539549impl < T > ops:: Index < ops:: Range < usize > > for [ T ] {
540550 type Output = [ T ] ;
@@ -554,6 +564,13 @@ impl<T> ops::Index<ops::Range<usize>> for [T] {
554564 }
555565 }
556566}
567+
568+ /// Implements slicing with syntax `&self[.. end]`.
569+ ///
570+ /// Returns a slice of self from the beginning until but not including
571+ /// the index `end`.
572+ ///
573+ /// Equivalent to `&self[0 .. end]`
557574#[ stable( feature = "rust1" , since = "1.0.0" ) ]
558575impl < T > ops:: Index < ops:: RangeTo < usize > > for [ T ] {
559576 type Output = [ T ] ;
@@ -563,6 +580,12 @@ impl<T> ops::Index<ops::RangeTo<usize>> for [T] {
563580 self . index ( 0 .. index. end )
564581 }
565582}
583+
584+ /// Implements slicing with syntax `&self[begin ..]`.
585+ ///
586+ /// Returns a slice of self from and including the index `begin` until the end.
587+ ///
588+ /// Equivalent to `&self[begin .. self.len()]`
566589#[ stable( feature = "rust1" , since = "1.0.0" ) ]
567590impl < T > ops:: Index < ops:: RangeFrom < usize > > for [ T ] {
568591 type Output = [ T ] ;
@@ -572,6 +595,12 @@ impl<T> ops::Index<ops::RangeFrom<usize>> for [T] {
572595 self . index ( index. start .. self . len ( ) )
573596 }
574597}
598+
599+ /// Implements slicing with syntax `&self[..]`.
600+ ///
601+ /// Returns a slice of the whole slice. This operation can not panic.
602+ ///
603+ /// Equivalent to `&self[0 .. self.len()]`
575604#[ stable( feature = "rust1" , since = "1.0.0" ) ]
576605impl < T > ops:: Index < RangeFull > for [ T ] {
577606 type Output = [ T ] ;
@@ -608,6 +637,16 @@ impl<T> ops::Index<ops::RangeToInclusive<usize>> for [T] {
608637 }
609638}
610639
640+ /// Implements mutable slicing with syntax `&mut self[begin .. end]`.
641+ ///
642+ /// Returns a slice of self for the index range [`begin`..`end`).
643+ ///
644+ /// This operation is `O(1)`.
645+ ///
646+ /// # Panics
647+ ///
648+ /// Requires that `begin <= end` and `end <= self.len()`,
649+ /// otherwise slicing will panic.
611650#[ stable( feature = "rust1" , since = "1.0.0" ) ]
612651impl < T > ops:: IndexMut < ops:: Range < usize > > for [ T ] {
613652 #[ inline]
@@ -625,13 +664,26 @@ impl<T> ops::IndexMut<ops::Range<usize>> for [T] {
625664 }
626665 }
627666}
667+
668+ /// Implements mutable slicing with syntax `&mut self[.. end]`.
669+ ///
670+ /// Returns a slice of self from the beginning until but not including
671+ /// the index `end`.
672+ ///
673+ /// Equivalent to `&mut self[0 .. end]`
628674#[ stable( feature = "rust1" , since = "1.0.0" ) ]
629675impl < T > ops:: IndexMut < ops:: RangeTo < usize > > for [ T ] {
630676 #[ inline]
631677 fn index_mut ( & mut self , index : ops:: RangeTo < usize > ) -> & mut [ T ] {
632678 self . index_mut ( 0 .. index. end )
633679 }
634680}
681+
682+ /// Implements mutable slicing with syntax `&mut self[begin ..]`.
683+ ///
684+ /// Returns a slice of self from and including the index `begin` until the end.
685+ ///
686+ /// Equivalent to `&mut self[begin .. self.len()]`
635687#[ stable( feature = "rust1" , since = "1.0.0" ) ]
636688impl < T > ops:: IndexMut < ops:: RangeFrom < usize > > for [ T ] {
637689 #[ inline]
@@ -640,6 +692,12 @@ impl<T> ops::IndexMut<ops::RangeFrom<usize>> for [T] {
640692 self . index_mut ( index. start .. len)
641693 }
642694}
695+
696+ /// Implements mutable slicing with syntax `&mut self[..]`.
697+ ///
698+ /// Returns a slice of the whole slice. This operation can not panic.
699+ ///
700+ /// Equivalent to `&mut self[0 .. self.len()]`
643701#[ stable( feature = "rust1" , since = "1.0.0" ) ]
644702impl < T > ops:: IndexMut < RangeFull > for [ T ] {
645703 #[ inline]
0 commit comments