File tree 2 files changed +12
-8
lines changed
2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -1527,23 +1527,27 @@ impl<T: Hash> Hash for Vec<T> {
1527
1527
1528
1528
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1529
1529
#[ rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`" ]
1530
- impl < T , I > Index < I > for Vec < T > where [ T ] : Index < I > {
1531
- type Output = <[ T ] as Index < I > >:: Output ;
1530
+ impl < T , I > Index < I > for Vec < T >
1531
+ where
1532
+ I : :: core:: slice:: SliceIndex < [ T ] > ,
1533
+ {
1534
+ type Output = I :: Output ;
1532
1535
1533
1536
#[ inline]
1534
1537
fn index ( & self , index : I ) -> & Self :: Output {
1535
- // NB indexing via implementation on slice
1536
- & ( * * self ) [ index]
1538
+ Index :: index ( & * * self , index)
1537
1539
}
1538
1540
}
1539
1541
1540
1542
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1541
1543
#[ rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`" ]
1542
- impl < T , I > IndexMut < I > for Vec < T > where [ T ] : IndexMut < I > {
1544
+ impl < T , I > IndexMut < I > for Vec < T >
1545
+ where
1546
+ I : :: core:: slice:: SliceIndex < [ T ] > ,
1547
+ {
1543
1548
#[ inline]
1544
1549
fn index_mut ( & mut self , index : I ) -> & mut Self :: Output {
1545
- // NB indexing via implementation on slice
1546
- & mut ( * * self ) [ index]
1550
+ IndexMut :: index_mut ( & mut * * self , index)
1547
1551
}
1548
1552
}
1549
1553
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ LL | x[0i32]; //~ ERROR E0277
5
5
| ^^^^^^^ slice indices are of type `usize` or ranges of `usize`
6
6
|
7
7
= help: the trait `std::slice::SliceIndex<[{integer}]>` is not implemented for `i32`
8
- = note: required because of the requirements on the impl of `std::ops::Index<i32>` for `[ {integer}] `
8
+ = note: required because of the requirements on the impl of `std::ops::Index<i32>` for `std::vec::Vec< {integer}> `
9
9
10
10
error: aborting due to previous error
11
11
You can’t perform that action at this time.
0 commit comments