Trait otter_api_tests::imports::failure::_core::ops::BitAnd 1.0.0[−][src]
pub trait BitAnd<Rhs = Self> { type Output; #[must_use] fn bitand(self, rhs: Rhs) -> Self::Output; }
Expand description
The bitwise AND operator &
.
Note that Rhs
is Self
by default, but this is not mandatory.
Examples
An implementation of BitAnd
for a wrapper around bool
.
use std::ops::BitAnd; #[derive(Debug, PartialEq)] struct Scalar(bool); impl BitAnd for Scalar { type Output = Self; // rhs is the "right-hand side" of the expression `a & b` fn bitand(self, rhs: Self) -> Self::Output { Self(self.0 & rhs.0) } } assert_eq!(Scalar(true) & Scalar(true), Scalar(true)); assert_eq!(Scalar(true) & Scalar(false), Scalar(false)); assert_eq!(Scalar(false) & Scalar(true), Scalar(false)); assert_eq!(Scalar(false) & Scalar(false), Scalar(false));
An implementation of BitAnd
for a wrapper around Vec<bool>
.
use std::ops::BitAnd; #[derive(Debug, PartialEq)] struct BooleanVector(Vec<bool>); impl BitAnd for BooleanVector { type Output = Self; fn bitand(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() ) } } let bv1 = BooleanVector(vec![true, true, false, false]); let bv2 = BooleanVector(vec![true, false, true, false]); let expected = BooleanVector(vec![true, false, false, false]); assert_eq!(bv1 & bv2, expected);
Associated Types
Required methods
Implementations on Foreign Types
impl BitAnd<Op> for Op
impl BitAnd<Op> for Op
impl BitAnd<EventMask> for EventMask
impl BitAnd<EventMask> for EventMask
impl BitAnd<WatchMask> for WatchMask
impl BitAnd<WatchMask> for WatchMask
impl BitAnd<Transformations> for Transformations
impl BitAnd<Transformations> for Transformations
impl BitAnd<FileType> for FileType
impl BitAnd<FileType> for FileType
impl<'_, '_, T, S1, S2> BitAnd<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
[src]
impl<'_, '_, T, S1, S2> BitAnd<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
[src]pub fn bitand(self, rhs: &HashSet<T, S>) -> HashSet<T, S>
pub fn bitand(self, rhs: &HashSet<T, S>) -> HashSet<T, S>
Returns the intersection of self
and rhs
as a new HashSet<T, S>
.
Examples
use hashbrown::HashSet; let a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); let b: HashSet<_> = vec![2, 3, 4].into_iter().collect(); let set = &a & &b; let mut i = 0; let expected = [2, 3]; for x in &set { assert!(expected.contains(x)); i += 1; } assert_eq!(i, expected.len());
type Output = HashSet<T, S>
Returns the intersection between the two sets of flags.
type Output = X509VerifyFlags
Returns the intersection between the two sets of flags.
type Output = SslOptions
Returns the intersection between the two sets of flags.
type Output = CMSOptions
Returns the intersection between the two sets of flags.
type Output = Pkcs7Flags
Returns the intersection between the two sets of flags.
type Output = SslSessionCacheMode
Returns the intersection between the two sets of flags.
type Output = SslVerifyMode
Returns the intersection between the two sets of flags.
type Output = ExtensionContext
Returns the intersection between the two sets of flags.
type Output = ShutdownState
Returns the intersection between the two sets of flags.
type Output = X509CheckFlags
Implementors
impl BitAnd<AccessFlags> for AccessFlags
impl BitAnd<AccessFlags> for AccessFlags
pub fn bitand(self, other: AccessFlags) -> AccessFlags
pub fn bitand(self, other: AccessFlags) -> AccessFlags
Returns the intersection between the two sets of flags.
type Output = AccessFlags
And with 1 ( 1 & 0 = 0)
And with 1 ( 1 & 1 = 1)
impl BitAnd<FallocateFlags> for FallocateFlags
impl BitAnd<FallocateFlags> for FallocateFlags
pub fn bitand(self, other: FallocateFlags) -> FallocateFlags
pub fn bitand(self, other: FallocateFlags) -> FallocateFlags
Returns the intersection between the two sets of flags.
type Output = FallocateFlags
impl BitAnd<SpliceFFlags> for SpliceFFlags
impl BitAnd<SpliceFFlags> for SpliceFFlags
pub fn bitand(self, other: SpliceFFlags) -> SpliceFFlags
pub fn bitand(self, other: SpliceFFlags) -> SpliceFFlags
Returns the intersection between the two sets of flags.
type Output = SpliceFFlags
impl BitAnd<DeleteModuleFlags> for DeleteModuleFlags
impl BitAnd<DeleteModuleFlags> for DeleteModuleFlags
pub fn bitand(self, other: DeleteModuleFlags) -> DeleteModuleFlags
pub fn bitand(self, other: DeleteModuleFlags) -> DeleteModuleFlags
Returns the intersection between the two sets of flags.
type Output = DeleteModuleFlags
impl BitAnd<ModuleInitFlags> for ModuleInitFlags
impl BitAnd<ModuleInitFlags> for ModuleInitFlags
pub fn bitand(self, other: ModuleInitFlags) -> ModuleInitFlags
pub fn bitand(self, other: ModuleInitFlags) -> ModuleInitFlags
Returns the intersection between the two sets of flags.
type Output = ModuleInitFlags
impl BitAnd<InterfaceFlags> for InterfaceFlags
impl BitAnd<InterfaceFlags> for InterfaceFlags
pub fn bitand(self, other: InterfaceFlags) -> InterfaceFlags
pub fn bitand(self, other: InterfaceFlags) -> InterfaceFlags
Returns the intersection between the two sets of flags.
type Output = InterfaceFlags
impl BitAnd<CloneFlags> for CloneFlags
impl BitAnd<CloneFlags> for CloneFlags
pub fn bitand(self, other: CloneFlags) -> CloneFlags
pub fn bitand(self, other: CloneFlags) -> CloneFlags
Returns the intersection between the two sets of flags.
type Output = CloneFlags
impl BitAnd<EpollCreateFlags> for EpollCreateFlags
impl BitAnd<EpollCreateFlags> for EpollCreateFlags
pub fn bitand(self, other: EpollCreateFlags) -> EpollCreateFlags
pub fn bitand(self, other: EpollCreateFlags) -> EpollCreateFlags
Returns the intersection between the two sets of flags.
type Output = EpollCreateFlags
impl BitAnd<EpollFlags> for EpollFlags
impl BitAnd<EpollFlags> for EpollFlags
pub fn bitand(self, other: EpollFlags) -> EpollFlags
pub fn bitand(self, other: EpollFlags) -> EpollFlags
Returns the intersection between the two sets of flags.
type Output = EpollFlags
impl BitAnd<AddWatchFlags> for AddWatchFlags
impl BitAnd<AddWatchFlags> for AddWatchFlags
pub fn bitand(self, other: AddWatchFlags) -> AddWatchFlags
pub fn bitand(self, other: AddWatchFlags) -> AddWatchFlags
Returns the intersection between the two sets of flags.
type Output = AddWatchFlags
impl BitAnd<MemFdCreateFlag> for MemFdCreateFlag
impl BitAnd<MemFdCreateFlag> for MemFdCreateFlag
pub fn bitand(self, other: MemFdCreateFlag) -> MemFdCreateFlag
pub fn bitand(self, other: MemFdCreateFlag) -> MemFdCreateFlag
Returns the intersection between the two sets of flags.
type Output = MemFdCreateFlag
impl BitAnd<MRemapFlags> for MRemapFlags
impl BitAnd<MRemapFlags> for MRemapFlags
pub fn bitand(self, other: MRemapFlags) -> MRemapFlags
pub fn bitand(self, other: MRemapFlags) -> MRemapFlags
Returns the intersection between the two sets of flags.
type Output = MRemapFlags
impl BitAnd<MlockAllFlags> for MlockAllFlags
impl BitAnd<MlockAllFlags> for MlockAllFlags
pub fn bitand(self, other: MlockAllFlags) -> MlockAllFlags
pub fn bitand(self, other: MlockAllFlags) -> MlockAllFlags
Returns the intersection between the two sets of flags.
type Output = MlockAllFlags
impl BitAnd<QuotaValidFlags> for QuotaValidFlags
impl BitAnd<QuotaValidFlags> for QuotaValidFlags
pub fn bitand(self, other: QuotaValidFlags) -> QuotaValidFlags
pub fn bitand(self, other: QuotaValidFlags) -> QuotaValidFlags
Returns the intersection between the two sets of flags.
type Output = QuotaValidFlags
impl BitAnd<ControlFlags> for ControlFlags
impl BitAnd<ControlFlags> for ControlFlags
pub fn bitand(self, other: ControlFlags) -> ControlFlags
pub fn bitand(self, other: ControlFlags) -> ControlFlags
Returns the intersection between the two sets of flags.
type Output = ControlFlags
impl BitAnd<InputFlags> for InputFlags
impl BitAnd<InputFlags> for InputFlags
pub fn bitand(self, other: InputFlags) -> InputFlags
pub fn bitand(self, other: InputFlags) -> InputFlags
Returns the intersection between the two sets of flags.
type Output = InputFlags
impl BitAnd<LocalFlags> for LocalFlags
impl BitAnd<LocalFlags> for LocalFlags
pub fn bitand(self, other: LocalFlags) -> LocalFlags
pub fn bitand(self, other: LocalFlags) -> LocalFlags
Returns the intersection between the two sets of flags.
type Output = LocalFlags
impl BitAnd<OutputFlags> for OutputFlags
impl BitAnd<OutputFlags> for OutputFlags
pub fn bitand(self, other: OutputFlags) -> OutputFlags
pub fn bitand(self, other: OutputFlags) -> OutputFlags
Returns the intersection between the two sets of flags.
type Output = OutputFlags
impl BitAnd<TimerFlags> for TimerFlags
impl BitAnd<TimerFlags> for TimerFlags
pub fn bitand(self, other: TimerFlags) -> TimerFlags
pub fn bitand(self, other: TimerFlags) -> TimerFlags
Returns the intersection between the two sets of flags.
type Output = TimerFlags
impl BitAnd<TimerSetTimeFlags> for TimerSetTimeFlags
impl BitAnd<TimerSetTimeFlags> for TimerSetTimeFlags
pub fn bitand(self, other: TimerSetTimeFlags) -> TimerSetTimeFlags
pub fn bitand(self, other: TimerSetTimeFlags) -> TimerSetTimeFlags
Returns the intersection between the two sets of flags.
type Output = TimerSetTimeFlags
impl BitAnd<WaitPidFlag> for WaitPidFlag
impl BitAnd<WaitPidFlag> for WaitPidFlag
pub fn bitand(self, other: WaitPidFlag) -> WaitPidFlag
pub fn bitand(self, other: WaitPidFlag) -> WaitPidFlag
Returns the intersection between the two sets of flags.
type Output = WaitPidFlag
Returns the intersection of self
and rhs
as a new BTreeSet<T>
.
Examples
use std::collections::BTreeSet; let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect(); let b: BTreeSet<_> = vec![2, 3, 4].into_iter().collect(); let result = &a & &b; let result_vec: Vec<_> = result.into_iter().collect(); assert_eq!(result_vec, [2, 3]);
Returns the intersection of self
and rhs
as a new HashSet<T, S>
.
Examples
use std::collections::HashSet; let a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); let b: HashSet<_> = vec![2, 3, 4].into_iter().collect(); let set = &a & &b; let mut i = 0; let expected = [2, 3]; for x in &set { assert!(expected.contains(x)); i += 1; } assert_eq!(i, expected.len());
And with 0 ( 0 & B = 0)
Anding unsigned integers.
We use our PrivateAnd
operator and then Trim
the output.