Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced self-reflective explicit types with clearer Self or Self::… in stdlib docs #59275

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// }
/// }
Expand Down Expand Up @@ -233,7 +233,7 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
/// format: BookFormat,
/// }
/// impl PartialEq for Book {
/// fn eq(&self, other: &Book) -> bool {
/// fn eq(&self, other: &Self) -> bool {
/// self.isbn == other.isbn
/// }
/// }
Expand Down Expand Up @@ -493,19 +493,19 @@ impl<T: Ord> Ord for Reverse<T> {
/// }
///
/// 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<Ordering> {
/// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
/// Some(self.cmp(other))
/// }
/// }
///
/// impl PartialEq for Person {
/// fn eq(&self, other: &Person) -> bool {
/// fn eq(&self, other: &Self) -> bool {
/// self.height == other.height
/// }
/// }
Expand Down Expand Up @@ -691,13 +691,13 @@ impl PartialOrd for Ordering {
/// }
///
/// impl PartialOrd for Person {
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
/// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
/// 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
/// }
/// }
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
//! type Item = usize;
//!
//! // next() is the only required method
//! fn next(&mut self) -> Option<usize> {
//! fn next(&mut self) -> Option<Self::Item> {
//! // Increment our count. This is why we started at zero.
//! self.count += 1;
//!
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub trait FromIterator<A>: Sized {
/// // and we'll implement IntoIterator
/// impl IntoIterator for MyCollection {
/// type Item = i32;
/// type IntoIter = ::std::vec::IntoIter<i32>;
/// type IntoIter = ::std::vec::IntoIter<Self::Item>;
///
/// fn into_iter(self) -> Self::IntoIter {
/// self.0.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/traits/exact_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/// # }
/// # impl Iterator for Counter {
/// # type Item = usize;
/// # fn next(&mut self) -> Option<usize> {
/// # fn next(&mut self) -> Option<Self::Item> {
/// # self.count += 1;
/// # if self.count < 6 {
/// # Some(self.count)
Expand Down
40 changes: 20 additions & 20 deletions src/libcore/ops/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
/// }
Expand All @@ -50,10 +50,10 @@
///
/// // Notice that the implementation uses the associated type `Output`.
/// impl<T: Add<Output = T>> Add for Point<T> {
/// type Output = Point<T>;
/// type Output = Self;
///
/// fn add(self, other: Point<T>) -> Point<T> {
/// Point {
/// fn add(self, other: Self) -> Self::Output {
/// Self {
/// x: self.x + other.x,
/// y: self.y + other.y,
/// }
Expand Down Expand Up @@ -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<T: Sub<Output = T>> Sub for Point<T> {
/// type Output = Point<T>;
/// type Output = Self;
///
/// fn sub(self, other: Point<T>) -> Point<T> {
/// fn sub(self, other: Self) -> Self::Output {
/// Point {
/// x: self.x - other.x,
/// y: self.y - other.y,
Expand Down Expand Up @@ -280,9 +280,9 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// struct Vector { value: Vec<usize> }
///
/// impl Mul<Scalar> 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() }
/// }
/// }
Expand Down Expand Up @@ -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`!");
/// }
Expand Down Expand Up @@ -404,9 +404,9 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// struct Vector { value: Vec<f32> }
///
/// impl Div<Scalar> 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() }
/// }
/// }
Expand Down Expand Up @@ -485,9 +485,9 @@ div_impl_float! { f32 f64 }
/// }
///
/// impl<'a, T> Rem<usize> 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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
/// };
Expand Down Expand Up @@ -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,
/// };
Expand Down
16 changes: 8 additions & 8 deletions src/libcore/ops/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
/// }
/// }
Expand All @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
/// }
/// }
Expand All @@ -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()
Expand Down Expand Up @@ -355,7 +355,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
/// impl<T: Clone> Shl<usize> for SpinVector<T> {
/// type Output = Self;
///
/// fn shl(self, rhs: usize) -> SpinVector<T> {
/// 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<T> = vec![];
Expand Down Expand Up @@ -464,7 +464,7 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 }
/// impl<T: Clone> Shr<usize> for SpinVector<T> {
/// type Output = Self;
///
/// fn shr(self, rhs: usize) -> SpinVector<T> {
/// 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<T> = vec![];
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/// impl<T> Deref for DerefExample<T> {
/// type Target = T;
///
/// fn deref(&self) -> &T {
/// fn deref(&self) -> &Self::Target {
/// &self.value
/// }
/// }
Expand Down Expand Up @@ -139,13 +139,13 @@ impl<T: ?Sized> Deref for &mut T {
/// impl<T> Deref for DerefMutExample<T> {
/// type Target = T;
///
/// fn deref(&self) -> &T {
/// fn deref(&self) -> &Self::Target {
/// &self.value
/// }
/// }
///
/// impl<T> DerefMut for DerefMutExample<T> {
/// fn deref_mut(&mut self) -> &mut T {
/// fn deref_mut(&mut self) -> &mut Self::Target {
/// &mut self.value
/// }
/// }
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/ops/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/// impl Index<Nucleotide> 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,
Expand Down Expand Up @@ -105,7 +105,7 @@ pub trait Index<Idx: ?Sized> {
/// impl Index<Side> 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,
Expand All @@ -115,7 +115,7 @@ pub trait Index<Idx: ?Sized> {
/// }
///
/// impl IndexMut<Side> 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,
Expand Down