Trait scale_info::prelude::ops::BitOr

1.0.0 · source ·
pub trait BitOr<Rhs = Self> {
    type Output;

    fn bitor(self, rhs: Rhs) -> Self::Output;
}
Expand description

The bitwise OR operator |.

Note that Rhs is Self by default, but this is not mandatory.

Examples

An implementation of BitOr for a wrapper around bool.

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::Output {
        Self(self.0 | rhs.0)
    }
}

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));

An implementation of BitOr for a wrapper around Vec<bool>.

use std::ops::BitOr;

#[derive(Debug, PartialEq)]
struct BooleanVector(Vec<bool>);

impl BitOr for BooleanVector {
    type Output = Self;

    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()
        )
    }
}

let bv1 = BooleanVector(vec![true, true, false, false]);
let bv2 = BooleanVector(vec![true, false, true, false]);
let expected = BooleanVector(vec![true, true, true, false]);
assert_eq!(bv1 | bv2, expected);

Required Associated Types§

The resulting type after applying the | operator.

Required Methods§

Performs the | operation.

Examples
assert_eq!(true | false, true);
assert_eq!(false | false, false);
assert_eq!(5u8 | 1u8, 5);
assert_eq!(5u8 | 2u8, 7);

Implementors§

impl<T, S> BitOr<&AHashSet<T, S>> for &AHashSet<T, S>where
    T: Eq + Hash + Clone,
    S: BuildHasher + Default,

impl BitOr<Limb> for Limb

impl<const LIMBS: usize> BitOr<UInt<LIMBS>> for UInt<LIMBS>

impl<const LIMBS: usize> BitOr<&UInt<LIMBS>> for UInt<LIMBS>

impl<const LIMBS: usize> BitOr<UInt<LIMBS>> for &UInt<LIMBS>

impl<const LIMBS: usize> BitOr<&UInt<LIMBS>> for &UInt<LIMBS>

impl<const LIMBS: usize> BitOr<Wrapping<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

impl<const LIMBS: usize> BitOr<&Wrapping<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

impl<const LIMBS: usize> BitOr<Wrapping<UInt<LIMBS>>> for &Wrapping<UInt<LIMBS>>

impl<const LIMBS: usize> BitOr<&Wrapping<UInt<LIMBS>>> for &Wrapping<UInt<LIMBS>>

impl<T, B> BitOr<B> for BitFlags<T>where
    T: BitFlag,
    B: Into<BitFlags<T>>,

impl<Frac> BitOr<FixedU8<Frac>> for FixedU8<Frac>

impl<Frac> BitOr<FixedU8<Frac>> for &FixedU8<Frac>

impl<Frac> BitOr<&FixedU8<Frac>> for FixedU8<Frac>

impl<Frac> BitOr<&FixedU8<Frac>> for &FixedU8<Frac>

impl<Frac> BitOr<FixedU16<Frac>> for FixedU16<Frac>

impl<Frac> BitOr<FixedU16<Frac>> for &FixedU16<Frac>

impl<Frac> BitOr<&FixedU16<Frac>> for FixedU16<Frac>

impl<Frac> BitOr<&FixedU16<Frac>> for &FixedU16<Frac>

impl<Frac> BitOr<FixedU32<Frac>> for FixedU32<Frac>

impl<Frac> BitOr<FixedU32<Frac>> for &FixedU32<Frac>

impl<Frac> BitOr<&FixedU32<Frac>> for FixedU32<Frac>

impl<Frac> BitOr<&FixedU32<Frac>> for &FixedU32<Frac>

impl<Frac> BitOr<FixedU64<Frac>> for FixedU64<Frac>

impl<Frac> BitOr<FixedU64<Frac>> for &FixedU64<Frac>

impl<Frac> BitOr<&FixedU64<Frac>> for FixedU64<Frac>

impl<Frac> BitOr<&FixedU64<Frac>> for &FixedU64<Frac>

impl<Frac> BitOr<FixedU128<Frac>> for FixedU128<Frac>

impl<Frac> BitOr<FixedU128<Frac>> for &FixedU128<Frac>

impl<Frac> BitOr<&FixedU128<Frac>> for FixedU128<Frac>

impl<Frac> BitOr<&FixedU128<Frac>> for &FixedU128<Frac>

impl<Frac> BitOr<FixedI8<Frac>> for FixedI8<Frac>

impl<Frac> BitOr<FixedI8<Frac>> for &FixedI8<Frac>

impl<Frac> BitOr<&FixedI8<Frac>> for FixedI8<Frac>

impl<Frac> BitOr<&FixedI8<Frac>> for &FixedI8<Frac>

impl<Frac> BitOr<FixedI16<Frac>> for FixedI16<Frac>

impl<Frac> BitOr<FixedI16<Frac>> for &FixedI16<Frac>

impl<Frac> BitOr<&FixedI16<Frac>> for FixedI16<Frac>

impl<Frac> BitOr<&FixedI16<Frac>> for &FixedI16<Frac>

impl<Frac> BitOr<FixedI32<Frac>> for FixedI32<Frac>

impl<Frac> BitOr<FixedI32<Frac>> for &FixedI32<Frac>

impl<Frac> BitOr<&FixedI32<Frac>> for FixedI32<Frac>

impl<Frac> BitOr<&FixedI32<Frac>> for &FixedI32<Frac>

impl<Frac> BitOr<FixedI64<Frac>> for FixedI64<Frac>

impl<Frac> BitOr<FixedI64<Frac>> for &FixedI64<Frac>

impl<Frac> BitOr<&FixedI64<Frac>> for FixedI64<Frac>

impl<Frac> BitOr<&FixedI64<Frac>> for &FixedI64<Frac>

impl<Frac> BitOr<FixedI128<Frac>> for FixedI128<Frac>

impl<Frac> BitOr<FixedI128<Frac>> for &FixedI128<Frac>

impl<Frac> BitOr<&FixedI128<Frac>> for FixedI128<Frac>

impl<Frac> BitOr<&FixedI128<Frac>> for &FixedI128<Frac>

impl<F> BitOr<Unwrapped<F>> for Unwrapped<F>where
    F: BitOr<F, Output = F>,

impl<F> BitOr<Unwrapped<F>> for &Unwrapped<F>where
    for<'a> &'a F: BitOr<F, Output = F>,

impl<F> BitOr<&Unwrapped<F>> for Unwrapped<F>where
    for<'a> F: BitOr<&'a F, Output = F>,

impl<F> BitOr<&Unwrapped<F>> for &Unwrapped<F>where
    for<'a, 'b> &'a F: BitOr<&'b F, Output = F>,

impl<F> BitOr<Wrapping<F>> for Wrapping<F>where
    F: BitOr<F, Output = F>,

impl<F> BitOr<Wrapping<F>> for &Wrapping<F>where
    for<'a> &'a F: BitOr<F, Output = F>,

impl<F> BitOr<&Wrapping<F>> for Wrapping<F>where
    for<'a> F: BitOr<&'a F, Output = F>,

impl<F> BitOr<&Wrapping<F>> for &Wrapping<F>where
    for<'a, 'b> &'a F: BitOr<&'b F, Output = F>,

impl<'a> BitOr<&'a FixedBitSet> for &'a FixedBitSet

impl<T, S, A> BitOr<&HashSet<T, S, A>> for &HashSet<T, S, A>where
    T: Eq + Hash + Clone,
    S: BuildHasher + Default,
    A: Allocator + Clone,

impl<T, S1, S2> BitOr<&IndexSet<T, S2>> for &IndexSet<T, S1>where
    T: Eq + Hash + Clone,
    S1: BuildHasher + Default,
    S2: BuildHasher,

impl BitOr<&BigInt> for &BigInt

impl<'a> BitOr<BigInt> for &'a BigInt

impl BitOr<&BigInt> for BigInt

impl BitOr<BigInt> for BigInt

impl BitOr<&Number> for &Number

impl<'a> BitOr<Number> for &'a Number

impl BitOr<&Number> for Number

impl BitOr<Number> for Number

impl<'a, 'b, T, S> BitOr<&'b LinkedHashSet<T, S>> for &'a LinkedHashSet<T, S>where
    T: Eq + Hash + Clone,
    S: BuildHasher + Default,

impl BitOr<OFlag> for OFlag

impl BitOr<FdFlag> for FdFlag

impl BitOr<SFlag> for SFlag

impl BitOr<Mode> for Mode

impl BitOr<BigInt> for BigInt

impl<'a> BitOr<BigInt> for &'a BigInt

impl<'a, 'b> BitOr<&'b BigInt> for &'a BigInt

impl<'a> BitOr<&'a BigInt> for BigInt

impl<'a> BitOr<BigUint> for &'a BigUint

impl<'a, 'b> BitOr<&'b BigUint> for &'a BigUint

impl<'a> BitOr<&'a BigUint> for BigUint

impl<R: RuleType> BitOr<Op<R>> for Op<R>

impl<R: RuleType> BitOr<Operator<R>> for Operator<R>

impl BitOr<U128> for U128

impl BitOr<U256> for U256

impl BitOr<U512> for U512

impl<'l, 'r> BitOr<&'r H128> for &'l H128

impl BitOr<H128> for H128

impl<'l, 'r> BitOr<&'r H160> for &'l H160

impl BitOr<H160> for H160

impl<'l, 'r> BitOr<&'r H256> for &'l H256

impl BitOr<H256> for H256

impl<'l, 'r> BitOr<&'r H384> for &'l H384

impl BitOr<H384> for H384

impl<'l, 'r> BitOr<&'r H512> for &'l H512

impl BitOr<H512> for H512

impl<'l, 'r> BitOr<&'r H768> for &'l H768

impl BitOr<H768> for H768

impl BitOr<Access> for Access

impl BitOr<Mode> for Mode

impl BitOr<OFlags> for OFlags

impl BitOr<AutoSimd<[bool; 1]>> for AutoSimd<[bool; 1]>

impl BitOr<AutoSimd<[bool; 2]>> for AutoSimd<[bool; 2]>

impl BitOr<AutoSimd<[bool; 4]>> for AutoSimd<[bool; 4]>

impl BitOr<AutoSimd<[bool; 8]>> for AutoSimd<[bool; 8]>

impl BitOr<AutoSimd<[bool; 16]>> for AutoSimd<[bool; 16]>

impl BitOr<AutoSimd<[bool; 32]>> for AutoSimd<[bool; 32]>

impl BitOr<Choice> for Choice

impl BitOr<Ready> for Ready

impl BitOr<B0> for B0

impl BitOr<B1> for B0

impl<Rhs: Bit> BitOr<Rhs> for B1

impl<U: Unsigned> BitOr<U> for UTerm

impl<B: Bit, U: Unsigned> BitOr<UTerm> for UInt<U, B>

impl<Ul, Ur: Unsigned> BitOr<UInt<Ur, B0>> for UInt<Ul, B0>where
    Ul: BitOr<Ur> + Unsigned,

impl<Ul, Ur: Unsigned> BitOr<UInt<Ur, B1>> for UInt<Ul, B0>where
    Ul: BitOr<Ur> + Unsigned,

impl<Ul, Ur: Unsigned> BitOr<UInt<Ur, B0>> for UInt<Ul, B1>where
    Ul: BitOr<Ur> + Unsigned,

impl<Ul, Ur: Unsigned> BitOr<UInt<Ur, B1>> for UInt<Ul, B1>where
    Ul: BitOr<Ur> + Unsigned,

impl BitOr<&JsValue> for &JsValue

impl<'a> BitOr<JsValue> for &'a JsValue

impl BitOr<&JsValue> for JsValue