std::ops::BitOr
Trait std::ops::BitOr
#[lang = "bitor"] pub trait BitOr<RHS = Self> { type Output; fn bitor(self, rhs: RHS) -> Self::Output; }
The bitwise OR operator |
.
Examples
In this example, the |
operator is lifted to a trivial Scalar
type.
use std::ops::BitOr; #[derive(Debug, PartialEq)] struct Scalar(bool); impl BitOr for Scalar { type Output = Self; // rhs is the "right-hand side" of the expression `a | b` fn bitor(self, rhs: Self) -> Self { Scalar(self.0 | rhs.0) } } fn main() { assert_eq!(Scalar(true) | Scalar(true), Scalar(true)); assert_eq!(Scalar(true) | Scalar(false), Scalar(true)); assert_eq!(Scalar(false) | Scalar(true), Scalar(true)); assert_eq!(Scalar(false) | Scalar(false), Scalar(false));