@@ -1873,7 +1873,7 @@ macro_rules! shr_assign_impl_all {
1873
1873
shr_assign_impl_all ! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
1874
1874
1875
1875
/// The `Index` trait is used to specify the functionality of indexing operations
1876
- /// like `arr[idx ]` when used in an immutable context.
1876
+ /// like `container[index ]` when used in an immutable context.
1877
1877
///
1878
1878
/// # Examples
1879
1879
///
@@ -1924,50 +1924,50 @@ pub trait Index<Idx: ?Sized> {
1924
1924
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1925
1925
type Output : ?Sized ;
1926
1926
1927
- /// The method for the indexing (`Foo[Bar ]`) operation
1927
+ /// The method for the indexing (`container[index ]`) operation
1928
1928
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1929
1929
fn index ( & self , index : Idx ) -> & Self :: Output ;
1930
1930
}
1931
1931
1932
1932
/// The `IndexMut` trait is used to specify the functionality of indexing
1933
- /// operations like `arr[idx ]`, when used in a mutable context.
1933
+ /// operations like `container[index ]`, when used in a mutable context.
1934
1934
///
1935
1935
/// # Examples
1936
1936
///
1937
- /// A trivial implementation of `IndexMut`. When `Foo[Bar]` happens, it ends up
1938
- /// calling `index_mut`, and therefore, `main` prints `Indexing!`.
1937
+ /// A trivial implementation of `IndexMut` for a type `Foo`. When `&mut Foo[2]`
1938
+ /// happens, it ends up calling `index_mut`, and therefore, `main` prints
1939
+ /// `Mutable indexing with 2!`.
1939
1940
///
1940
1941
/// ```
1941
1942
/// use std::ops::{Index, IndexMut};
1942
1943
///
1943
1944
/// #[derive(Copy, Clone)]
1944
1945
/// struct Foo;
1945
- /// struct Bar;
1946
1946
///
1947
- /// impl Index<Bar > for Foo {
1947
+ /// impl Index<usize > for Foo {
1948
1948
/// type Output = Foo;
1949
1949
///
1950
- /// fn index<'a>(&'a self, _index: Bar ) -> &'a Foo {
1950
+ /// fn index(& self, _index: usize ) -> &Foo {
1951
1951
/// self
1952
1952
/// }
1953
1953
/// }
1954
1954
///
1955
- /// impl IndexMut<Bar > for Foo {
1956
- /// fn index_mut<'a>(&'a mut self, _index: Bar ) -> &'a mut Foo {
1957
- /// println!("Indexing!" );
1955
+ /// impl IndexMut<usize > for Foo {
1956
+ /// fn index_mut(& mut self, index: usize ) -> &mut Foo {
1957
+ /// println!("Mutable indexing with {}!", index );
1958
1958
/// self
1959
1959
/// }
1960
1960
/// }
1961
1961
///
1962
1962
/// fn main() {
1963
- /// &mut Foo[Bar ];
1963
+ /// &mut Foo[2 ];
1964
1964
/// }
1965
1965
/// ```
1966
1966
#[ lang = "index_mut" ]
1967
1967
#[ rustc_on_unimplemented = "the type `{Self}` cannot be mutably indexed by `{Idx}`" ]
1968
1968
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1969
1969
pub trait IndexMut < Idx : ?Sized > : Index < Idx > {
1970
- /// The method for the indexing (`Foo[Bar ]`) operation
1970
+ /// The method for the mutable indexing (`container[index ]`) operation
1971
1971
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1972
1972
fn index_mut ( & mut self , index : Idx ) -> & mut Self :: Output ;
1973
1973
}
0 commit comments