Skip to content

Commit

Permalink
Rollup merge of rust-lang#78620 - gabhijit:bitops_doc_fix, r=m-ou-se
Browse files Browse the repository at this point in the history
Trivial fixes to bitwise operator documentation

Added fixes to documentation of `BitAnd`, `BitOr`, `BitXor` and
`BitAndAssign`, where the documentation for implementation on
`Vector<bool>` was using logical operators in place of the bitwise
operators.

r? @steveklabnik
cc rust-lang#78619
  • Loading branch information
m-ou-se authored Nov 1, 2020
2 parents b5075b7 + d422e24 commit c43eb4a
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions library/core/src/ops/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
/// .map(|(x, y)| *x & *y)
/// .collect()
/// )
/// }
/// }
///
Expand Down Expand Up @@ -207,7 +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().zip(rhs.iter()).map(|(x, y)| *x || *y).collect())
/// Self(
/// lhs.iter()
/// .zip(rhs.iter())
/// .map(|(x, y)| *x | *y)
/// .collect()
/// )
/// }
/// }
///
Expand Down Expand Up @@ -302,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) && !(*x && *y))
/// .collect())
/// .map(|(x, y)| *x ^ *y)
/// .collect()
/// )
/// }
/// }
///
Expand Down Expand Up @@ -643,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()
/// );
/// }
/// }
///
Expand Down

0 comments on commit c43eb4a

Please sign in to comment.