@@ -97,8 +97,7 @@ pub trait SliceExt {
97
97
98
98
#[ stable( feature = "core" , since = "1.6.0" ) ]
99
99
fn get < I > ( & self , index : I ) -> Option < & I :: Output >
100
- where I : SliceIndex < Self :: Item > ;
101
-
100
+ where I : SliceIndex < Self > ;
102
101
#[ stable( feature = "core" , since = "1.6.0" ) ]
103
102
fn first ( & self ) -> Option < & Self :: Item > ;
104
103
@@ -113,8 +112,7 @@ pub trait SliceExt {
113
112
114
113
#[ stable( feature = "core" , since = "1.6.0" ) ]
115
114
unsafe fn get_unchecked < I > ( & self , index : I ) -> & I :: Output
116
- where I : SliceIndex < Self :: Item > ;
117
-
115
+ where I : SliceIndex < Self > ;
118
116
#[ stable( feature = "core" , since = "1.6.0" ) ]
119
117
fn as_ptr ( & self ) -> * const Self :: Item ;
120
118
@@ -141,8 +139,7 @@ pub trait SliceExt {
141
139
142
140
#[ stable( feature = "core" , since = "1.6.0" ) ]
143
141
fn get_mut < I > ( & mut self , index : I ) -> Option < & mut I :: Output >
144
- where I : SliceIndex < Self :: Item > ;
145
-
142
+ where I : SliceIndex < Self > ;
146
143
#[ stable( feature = "core" , since = "1.6.0" ) ]
147
144
fn iter_mut ( & mut self ) -> IterMut < Self :: Item > ;
148
145
@@ -184,8 +181,7 @@ pub trait SliceExt {
184
181
185
182
#[ stable( feature = "core" , since = "1.6.0" ) ]
186
183
unsafe fn get_unchecked_mut < I > ( & mut self , index : I ) -> & mut I :: Output
187
- where I : SliceIndex < Self :: Item > ;
188
-
184
+ where I : SliceIndex < Self > ;
189
185
#[ stable( feature = "core" , since = "1.6.0" ) ]
190
186
fn as_mut_ptr ( & mut self ) -> * mut Self :: Item ;
191
187
@@ -337,7 +333,7 @@ impl<T> SliceExt for [T] {
337
333
338
334
#[ inline]
339
335
fn get < I > ( & self , index : I ) -> Option < & I :: Output >
340
- where I : SliceIndex < T >
336
+ where I : SliceIndex < [ T ] >
341
337
{
342
338
index. get ( self )
343
339
}
@@ -365,7 +361,7 @@ impl<T> SliceExt for [T] {
365
361
366
362
#[ inline]
367
363
unsafe fn get_unchecked < I > ( & self , index : I ) -> & I :: Output
368
- where I : SliceIndex < T >
364
+ where I : SliceIndex < [ T ] >
369
365
{
370
366
index. get_unchecked ( self )
371
367
}
@@ -406,7 +402,7 @@ impl<T> SliceExt for [T] {
406
402
407
403
#[ inline]
408
404
fn get_mut < I > ( & mut self , index : I ) -> Option < & mut I :: Output >
409
- where I : SliceIndex < T >
405
+ where I : SliceIndex < [ T ] >
410
406
{
411
407
index. get_mut ( self )
412
408
}
@@ -538,7 +534,7 @@ impl<T> SliceExt for [T] {
538
534
539
535
#[ inline]
540
536
unsafe fn get_unchecked_mut < I > ( & mut self , index : I ) -> & mut I :: Output
541
- where I : SliceIndex < T >
537
+ where I : SliceIndex < [ T ] >
542
538
{
543
539
index. get_unchecked_mut ( self )
544
540
}
@@ -631,7 +627,7 @@ impl<T> SliceExt for [T] {
631
627
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
632
628
#[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
633
629
impl < T , I > ops:: Index < I > for [ T ]
634
- where I : SliceIndex < T >
630
+ where I : SliceIndex < [ T ] >
635
631
{
636
632
type Output = I :: Output ;
637
633
@@ -644,7 +640,7 @@ impl<T, I> ops::Index<I> for [T]
644
640
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
645
641
#[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
646
642
impl < T , I > ops:: IndexMut < I > for [ T ]
647
- where I : SliceIndex < T >
643
+ where I : SliceIndex < [ T ] >
648
644
{
649
645
#[ inline]
650
646
fn index_mut ( & mut self , index : I ) -> & mut I :: Output {
@@ -667,37 +663,37 @@ fn slice_index_order_fail(index: usize, end: usize) -> ! {
667
663
/// A helper trait used for indexing operations.
668
664
#[ unstable( feature = "slice_get_slice" , issue = "35729" ) ]
669
665
#[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
670
- pub trait SliceIndex < T > {
666
+ pub trait SliceIndex < T : ? Sized > {
671
667
/// The output type returned by methods.
672
668
type Output : ?Sized ;
673
669
674
670
/// Returns a shared reference to the output at this location, if in
675
671
/// bounds.
676
- fn get ( self , slice : & [ T ] ) -> Option < & Self :: Output > ;
672
+ fn get ( self , slice : & T ) -> Option < & Self :: Output > ;
677
673
678
674
/// Returns a mutable reference to the output at this location, if in
679
675
/// bounds.
680
- fn get_mut ( self , slice : & mut [ T ] ) -> Option < & mut Self :: Output > ;
676
+ fn get_mut ( self , slice : & mut T ) -> Option < & mut Self :: Output > ;
681
677
682
678
/// Returns a shared reference to the output at this location, without
683
679
/// performing any bounds checking.
684
- unsafe fn get_unchecked ( self , slice : & [ T ] ) -> & Self :: Output ;
680
+ unsafe fn get_unchecked ( self , slice : & T ) -> & Self :: Output ;
685
681
686
682
/// Returns a mutable reference to the output at this location, without
687
683
/// performing any bounds checking.
688
- unsafe fn get_unchecked_mut ( self , slice : & mut [ T ] ) -> & mut Self :: Output ;
684
+ unsafe fn get_unchecked_mut ( self , slice : & mut T ) -> & mut Self :: Output ;
689
685
690
686
/// Returns a shared reference to the output at this location, panicking
691
687
/// if out of bounds.
692
- fn index ( self , slice : & [ T ] ) -> & Self :: Output ;
688
+ fn index ( self , slice : & T ) -> & Self :: Output ;
693
689
694
690
/// Returns a mutable reference to the output at this location, panicking
695
691
/// if out of bounds.
696
- fn index_mut ( self , slice : & mut [ T ] ) -> & mut Self :: Output ;
692
+ fn index_mut ( self , slice : & mut T ) -> & mut Self :: Output ;
697
693
}
698
694
699
695
#[ stable( feature = "slice-get-slice-impls" , since = "1.15.0" ) ]
700
- impl < T > SliceIndex < T > for usize {
696
+ impl < T > SliceIndex < [ T ] > for usize {
701
697
type Output = T ;
702
698
703
699
#[ inline]
@@ -746,7 +742,7 @@ impl<T> SliceIndex<T> for usize {
746
742
}
747
743
748
744
#[ stable( feature = "slice-get-slice-impls" , since = "1.15.0" ) ]
749
- impl < T > SliceIndex < T > for ops:: Range < usize > {
745
+ impl < T > SliceIndex < [ T ] > for ops:: Range < usize > {
750
746
type Output = [ T ] ;
751
747
752
748
#[ inline]
@@ -807,7 +803,7 @@ impl<T> SliceIndex<T> for ops::Range<usize> {
807
803
}
808
804
809
805
#[ stable( feature = "slice-get-slice-impls" , since = "1.15.0" ) ]
810
- impl < T > SliceIndex < T > for ops:: RangeTo < usize > {
806
+ impl < T > SliceIndex < [ T ] > for ops:: RangeTo < usize > {
811
807
type Output = [ T ] ;
812
808
813
809
#[ inline]
@@ -842,7 +838,7 @@ impl<T> SliceIndex<T> for ops::RangeTo<usize> {
842
838
}
843
839
844
840
#[ stable( feature = "slice-get-slice-impls" , since = "1.15.0" ) ]
845
- impl < T > SliceIndex < T > for ops:: RangeFrom < usize > {
841
+ impl < T > SliceIndex < [ T ] > for ops:: RangeFrom < usize > {
846
842
type Output = [ T ] ;
847
843
848
844
#[ inline]
@@ -877,7 +873,7 @@ impl<T> SliceIndex<T> for ops::RangeFrom<usize> {
877
873
}
878
874
879
875
#[ stable( feature = "slice-get-slice-impls" , since = "1.15.0" ) ]
880
- impl < T > SliceIndex < T > for ops:: RangeFull {
876
+ impl < T > SliceIndex < [ T ] > for ops:: RangeFull {
881
877
type Output = [ T ] ;
882
878
883
879
#[ inline]
@@ -913,7 +909,7 @@ impl<T> SliceIndex<T> for ops::RangeFull {
913
909
914
910
915
911
#[ unstable( feature = "inclusive_range" , reason = "recently added, follows RFC" , issue = "28237" ) ]
916
- impl < T > SliceIndex < T > for ops:: RangeInclusive < usize > {
912
+ impl < T > SliceIndex < [ T ] > for ops:: RangeInclusive < usize > {
917
913
type Output = [ T ] ;
918
914
919
915
#[ inline]
@@ -976,7 +972,7 @@ impl<T> SliceIndex<T> for ops::RangeInclusive<usize> {
976
972
}
977
973
978
974
#[ unstable( feature = "inclusive_range" , reason = "recently added, follows RFC" , issue = "28237" ) ]
979
- impl < T > SliceIndex < T > for ops:: RangeToInclusive < usize > {
975
+ impl < T > SliceIndex < [ T ] > for ops:: RangeToInclusive < usize > {
980
976
type Output = [ T ] ;
981
977
982
978
#[ inline]
0 commit comments