From 66d68cdc6f5bb508052b890f8766a84a98533865 Mon Sep 17 00:00:00 2001 From: Abhijit Gadgil Date: Sun, 1 Nov 2020 08:22:25 +0530 Subject: [PATCH 1/3] Trivial fixes to bitwise operator documentation Added fixes to documentation of `BitAnd`, `BitOr`, `BitXor` and `BitAndAssign`, where the documentation for implementation on `Vector` was using logical operators in place of the bitwise operators. r? @steveklabnik cc #78619 --- library/core/src/ops/bit.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/core/src/ops/bit.rs b/library/core/src/ops/bit.rs index 6120da50c3cdf..3dae57938bec5 100644 --- a/library/core/src/ops/bit.rs +++ b/library/core/src/ops/bit.rs @@ -111,7 +111,7 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// assert_eq!(lhs.len(), rhs.len()); /// Self(lhs.iter() /// .zip(rhs.iter()) -/// .map(|(x, y)| *x && *y) +/// .map(|(x, y)| *x & *y) /// .collect()) /// } /// } @@ -207,7 +207,10 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// fn bitor(self, Self(rhs): Self) -> Self::Output { /// let Self(lhs) = self; /// assert_eq!(lhs.len(), rhs.len()); -/// Self(lhs.iter().zip(rhs.iter()).map(|(x, y)| *x || *y).collect()) +/// Self(lhs.iter() +/// .zip(rhs.iter()) +/// .map(|(x, y)| *x | *y) +/// .collect()) /// } /// } /// @@ -304,7 +307,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// assert_eq!(lhs.len(), rhs.len()); /// Self(lhs.iter() /// .zip(rhs.iter()) -/// .map(|(x, y)| (*x || *y) && !(*x && *y)) +/// .map(|(x, y)| *x ^ *y)) /// .collect()) /// } /// } @@ -646,7 +649,7 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// *self = Self(self.0 /// .iter() /// .zip(rhs.0.iter()) -/// .map(|(x, y)| *x && *y) +/// .map(|(x, y)| *x & *y) /// .collect()); /// } /// } From 7c88bcc3f6a055093eafff8d4cfb1dfcd813ebbe Mon Sep 17 00:00:00 2001 From: Abhijit Gadgil Date: Sun, 1 Nov 2020 09:08:19 +0530 Subject: [PATCH 2/3] Fixes incorrect paranthesis. --- library/core/src/ops/bit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/ops/bit.rs b/library/core/src/ops/bit.rs index 3dae57938bec5..b91f87be90af1 100644 --- a/library/core/src/ops/bit.rs +++ b/library/core/src/ops/bit.rs @@ -307,7 +307,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// assert_eq!(lhs.len(), rhs.len()); /// Self(lhs.iter() /// .zip(rhs.iter()) -/// .map(|(x, y)| *x ^ *y)) +/// .map(|(x, y)| *x ^ *y) /// .collect()) /// } /// } From d422e2424f08ebc420882e2a668174028341dc65 Mon Sep 17 00:00:00 2001 From: Abhijit Gadgil Date: Sun, 1 Nov 2020 18:53:22 +0530 Subject: [PATCH 3/3] documentation examples fixes in rustfmt convention --- library/core/src/ops/bit.rs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/library/core/src/ops/bit.rs b/library/core/src/ops/bit.rs index b91f87be90af1..51f8043817345 100644 --- a/library/core/src/ops/bit.rs +++ b/library/core/src/ops/bit.rs @@ -109,10 +109,12 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// fn bitand(self, Self(rhs): Self) -> Self::Output { /// let Self(lhs) = self; /// assert_eq!(lhs.len(), rhs.len()); -/// Self(lhs.iter() +/// Self( +/// lhs.iter() /// .zip(rhs.iter()) /// .map(|(x, y)| *x & *y) -/// .collect()) +/// .collect() +/// ) /// } /// } /// @@ -207,10 +209,12 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// fn bitor(self, Self(rhs): Self) -> Self::Output { /// let Self(lhs) = self; /// assert_eq!(lhs.len(), rhs.len()); -/// Self(lhs.iter() +/// Self( +/// lhs.iter() /// .zip(rhs.iter()) /// .map(|(x, y)| *x | *y) -/// .collect()) +/// .collect() +/// ) /// } /// } /// @@ -305,10 +309,12 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// fn bitxor(self, Self(rhs): Self) -> Self::Output { /// let Self(lhs) = self; /// assert_eq!(lhs.len(), rhs.len()); -/// Self(lhs.iter() +/// Self( +/// lhs.iter() /// .zip(rhs.iter()) /// .map(|(x, y)| *x ^ *y) -/// .collect()) +/// .collect() +/// ) /// } /// } /// @@ -646,11 +652,13 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// // `rhs` is the "right-hand side" of the expression `a &= b`. /// fn bitand_assign(&mut self, rhs: Self) { /// assert_eq!(self.0.len(), rhs.0.len()); -/// *self = Self(self.0 -/// .iter() -/// .zip(rhs.0.iter()) -/// .map(|(x, y)| *x & *y) -/// .collect()); +/// *self = Self( +/// self.0 +/// .iter() +/// .zip(rhs.0.iter()) +/// .map(|(x, y)| *x & *y) +/// .collect() +/// ); /// } /// } ///