diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 7de94d25c7618..ea52b0ea72120 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -72,7 +72,7 @@ use self::Ordering::*; /// } /// /// impl PartialEq for Book { -/// fn eq(&self, other: &Book) -> bool { +/// fn eq(&self, other: &Self) -> bool { /// self.isbn == other.isbn /// } /// } @@ -233,7 +233,7 @@ pub trait PartialEq { /// format: BookFormat, /// } /// impl PartialEq for Book { -/// fn eq(&self, other: &Book) -> bool { +/// fn eq(&self, other: &Self) -> bool { /// self.isbn == other.isbn /// } /// } @@ -493,19 +493,19 @@ impl Ord for Reverse { /// } /// /// impl Ord for Person { -/// fn cmp(&self, other: &Person) -> Ordering { +/// fn cmp(&self, other: &Self) -> Ordering { /// self.height.cmp(&other.height) /// } /// } /// /// impl PartialOrd for Person { -/// fn partial_cmp(&self, other: &Person) -> Option { +/// fn partial_cmp(&self, other: &Self) -> Option { /// Some(self.cmp(other)) /// } /// } /// /// impl PartialEq for Person { -/// fn eq(&self, other: &Person) -> bool { +/// fn eq(&self, other: &Self) -> bool { /// self.height == other.height /// } /// } @@ -691,13 +691,13 @@ impl PartialOrd for Ordering { /// } /// /// impl PartialOrd for Person { -/// fn partial_cmp(&self, other: &Person) -> Option { +/// fn partial_cmp(&self, other: &Self) -> Option { /// self.height.partial_cmp(&other.height) /// } /// } /// /// impl PartialEq for Person { -/// fn eq(&self, other: &Person) -> bool { +/// fn eq(&self, other: &Self) -> bool { /// self.height == other.height /// } /// } diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 5dcca7ee0ca01..e6a616b680228 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -101,7 +101,7 @@ //! type Item = usize; //! //! // next() is the only required method -//! fn next(&mut self) -> Option { +//! fn next(&mut self) -> Option { //! // Increment our count. This is why we started at zero. //! self.count += 1; //! diff --git a/src/libcore/iter/traits/collect.rs b/src/libcore/iter/traits/collect.rs index 5204f6a642509..cd61ab5c552b6 100644 --- a/src/libcore/iter/traits/collect.rs +++ b/src/libcore/iter/traits/collect.rs @@ -167,7 +167,7 @@ pub trait FromIterator: Sized { /// // and we'll implement IntoIterator /// impl IntoIterator for MyCollection { /// type Item = i32; -/// type IntoIter = ::std::vec::IntoIter; +/// type IntoIter = ::std::vec::IntoIter; /// /// fn into_iter(self) -> Self::IntoIter { /// self.0.into_iter() diff --git a/src/libcore/iter/traits/exact_size.rs b/src/libcore/iter/traits/exact_size.rs index d6eab40213edb..8fc4ac93daa68 100644 --- a/src/libcore/iter/traits/exact_size.rs +++ b/src/libcore/iter/traits/exact_size.rs @@ -45,7 +45,7 @@ /// # } /// # impl Iterator for Counter { /// # type Item = usize; -/// # fn next(&mut self) -> Option { +/// # fn next(&mut self) -> Option { /// # self.count += 1; /// # if self.count < 6 { /// # Some(self.count) diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 0252edee23125..c5e908d7bb86b 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -20,10 +20,10 @@ /// } /// /// impl Add for Point { -/// type Output = Point; +/// type Output = Self; /// -/// fn add(self, other: Point) -> Point { -/// Point { +/// fn add(self, other: Self) -> Self { +/// Self { /// x: self.x + other.x, /// y: self.y + other.y, /// } @@ -50,10 +50,10 @@ /// /// // Notice that the implementation uses the associated type `Output`. /// impl> Add for Point { -/// type Output = Point; +/// type Output = Self; /// -/// fn add(self, other: Point) -> Point { -/// Point { +/// fn add(self, other: Self) -> Self::Output { +/// Self { /// x: self.x + other.x, /// y: self.y + other.y, /// } @@ -158,9 +158,9 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// /// // Notice that the implementation uses the associated type `Output`. /// impl> Sub for Point { -/// type Output = Point; +/// type Output = Self; /// -/// fn sub(self, other: Point) -> Point { +/// fn sub(self, other: Self) -> Self::Output { /// Point { /// x: self.x - other.x, /// y: self.y - other.y, @@ -280,9 +280,9 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// struct Vector { value: Vec } /// /// impl Mul for Vector { -/// type Output = Vector; +/// type Output = Self; /// -/// fn mul(self, rhs: Scalar) -> Vector { +/// fn mul(self, rhs: Scalar) -> Self::Output { /// Vector { value: self.value.iter().map(|v| v * rhs.value).collect() } /// } /// } @@ -364,7 +364,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// // The division of rational numbers is a closed operation. /// type Output = Self; /// -/// fn div(self, rhs: Self) -> Self { +/// fn div(self, rhs: Self) -> Self::Output { /// if rhs.nominator == 0 { /// panic!("Cannot divide by zero-valued `Rational`!"); /// } @@ -404,9 +404,9 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// struct Vector { value: Vec } /// /// impl Div for Vector { -/// type Output = Vector; +/// type Output = Self; /// -/// fn div(self, rhs: Scalar) -> Vector { +/// fn div(self, rhs: Scalar) -> Self::Output { /// Vector { value: self.value.iter().map(|v| v / rhs.value).collect() } /// } /// } @@ -485,9 +485,9 @@ div_impl_float! { f32 f64 } /// } /// /// impl<'a, T> Rem for SplitSlice<'a, T> { -/// type Output = SplitSlice<'a, T>; +/// type Output = Self; /// -/// fn rem(self, modulus: usize) -> Self { +/// fn rem(self, modulus: usize) -> Self::Output { /// let len = self.slice.len(); /// let rem = len % modulus; /// let start = len - rem; @@ -571,7 +571,7 @@ rem_impl_float! { f32 f64 } /// impl Neg for Sign { /// type Output = Sign; /// -/// fn neg(self) -> Sign { +/// fn neg(self) -> Self::Output { /// match self { /// Sign::Negative => Sign::Positive, /// Sign::Zero => Sign::Zero, @@ -650,8 +650,8 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } /// } /// /// impl AddAssign for Point { -/// fn add_assign(&mut self, other: Point) { -/// *self = Point { +/// fn add_assign(&mut self, other: Self) { +/// *self = Self { /// x: self.x + other.x, /// y: self.y + other.y, /// }; @@ -706,8 +706,8 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// } /// /// impl SubAssign for Point { -/// fn sub_assign(&mut self, other: Point) { -/// *self = Point { +/// fn sub_assign(&mut self, other: Self) { +/// *self = Self { /// x: self.x - other.x, /// y: self.y - other.y, /// }; diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs index 2c9bf248633c4..c3615bdaafca9 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -17,7 +17,7 @@ /// impl Not for Answer { /// type Output = Answer; /// -/// fn not(self) -> Answer { +/// fn not(self) -> Self::Output { /// match self { /// Answer::Yes => Answer::No, /// Answer::No => Answer::Yes @@ -75,7 +75,7 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// type Output = Self; /// /// // rhs is the "right-hand side" of the expression `a & b` -/// fn bitand(self, rhs: Self) -> Self { +/// fn bitand(self, rhs: Self) -> Self::Output { /// Scalar(self.0 & rhs.0) /// } /// } @@ -97,7 +97,7 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// impl BitAnd for BooleanVector { /// type Output = Self; /// -/// fn bitand(self, BooleanVector(rhs): Self) -> Self { +/// fn bitand(self, BooleanVector(rhs): Self) -> Self::Output { /// let BooleanVector(lhs) = self; /// assert_eq!(lhs.len(), rhs.len()); /// BooleanVector(lhs.iter().zip(rhs.iter()).map(|(x, y)| *x && *y).collect()) @@ -181,7 +181,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// impl BitOr for BooleanVector { /// type Output = Self; /// -/// fn bitor(self, BooleanVector(rhs): Self) -> Self { +/// fn bitor(self, BooleanVector(rhs): Self) -> Self::Output { /// let BooleanVector(lhs) = self; /// assert_eq!(lhs.len(), rhs.len()); /// BooleanVector(lhs.iter().zip(rhs.iter()).map(|(x, y)| *x || *y).collect()) @@ -243,7 +243,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// type Output = Self; /// /// // rhs is the "right-hand side" of the expression `a ^ b` -/// fn bitxor(self, rhs: Self) -> Self { +/// fn bitxor(self, rhs: Self) -> Self::Output { /// Scalar(self.0 ^ rhs.0) /// } /// } @@ -265,7 +265,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// impl BitXor for BooleanVector { /// type Output = Self; /// -/// fn bitxor(self, BooleanVector(rhs): Self) -> Self { +/// fn bitxor(self, BooleanVector(rhs): Self) -> Self::Output { /// let BooleanVector(lhs) = self; /// assert_eq!(lhs.len(), rhs.len()); /// BooleanVector(lhs.iter() @@ -355,7 +355,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// impl Shl for SpinVector { /// type Output = Self; /// -/// fn shl(self, rhs: usize) -> SpinVector { +/// fn shl(self, rhs: usize) -> Self::Output { /// // Rotate the vector by `rhs` places. /// let (a, b) = self.vec.split_at(rhs); /// let mut spun_vector: Vec = vec![]; @@ -464,7 +464,7 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } /// impl Shr for SpinVector { /// type Output = Self; /// -/// fn shr(self, rhs: usize) -> SpinVector { +/// fn shr(self, rhs: usize) -> Self::Output { /// // Rotate the vector by `rhs` places. /// let (a, b) = self.vec.split_at(self.vec.len() - rhs); /// let mut spun_vector: Vec = vec![]; diff --git a/src/libcore/ops/deref.rs b/src/libcore/ops/deref.rs index eb76c2de11bec..e44a6c4d2a0e9 100644 --- a/src/libcore/ops/deref.rs +++ b/src/libcore/ops/deref.rs @@ -49,7 +49,7 @@ /// impl Deref for DerefExample { /// type Target = T; /// -/// fn deref(&self) -> &T { +/// fn deref(&self) -> &Self::Target { /// &self.value /// } /// } @@ -139,13 +139,13 @@ impl Deref for &mut T { /// impl Deref for DerefMutExample { /// type Target = T; /// -/// fn deref(&self) -> &T { +/// fn deref(&self) -> &Self::Target { /// &self.value /// } /// } /// /// impl DerefMut for DerefMutExample { -/// fn deref_mut(&mut self) -> &mut T { +/// fn deref_mut(&mut self) -> &mut Self::Target { /// &mut self.value /// } /// } diff --git a/src/libcore/ops/index.rs b/src/libcore/ops/index.rs index d4ed86142768d..3158f58e95806 100644 --- a/src/libcore/ops/index.rs +++ b/src/libcore/ops/index.rs @@ -33,7 +33,7 @@ /// impl Index for NucleotideCount { /// type Output = usize; /// -/// fn index(&self, nucleotide: Nucleotide) -> &usize { +/// fn index(&self, nucleotide: Nucleotide) -> &Self::Output { /// match nucleotide { /// Nucleotide::A => &self.a, /// Nucleotide::C => &self.c, @@ -105,7 +105,7 @@ pub trait Index { /// impl Index for Balance { /// type Output = Weight; /// -/// fn index<'a>(&'a self, index: Side) -> &'a Weight { +/// fn index<'a>(&'a self, index: Side) -> &'a Self::Output { /// println!("Accessing {:?}-side of balance immutably", index); /// match index { /// Side::Left => &self.left, @@ -115,7 +115,7 @@ pub trait Index { /// } /// /// impl IndexMut for Balance { -/// fn index_mut<'a>(&'a mut self, index: Side) -> &'a mut Weight { +/// fn index_mut<'a>(&'a mut self, index: Side) -> &'a mut Self::Output { /// println!("Accessing {:?}-side of balance mutably", index); /// match index { /// Side::Left => &mut self.left,