pub trait BitXor<Rhs = Self> {
type Output;
// Required method
fn bitxor(self, rhs: Rhs) -> Self::Output;
}
Expand description
The bitwise XOR operator ^
.
Note that Rhs
is Self
by default, but this is not mandatory.
§Examples
An implementation of BitXor
that lifts ^
to a wrapper around bool
.
use std::ops::BitXor;
#[derive(Debug, PartialEq)]
struct Scalar(bool);
impl BitXor for Scalar {
type Output = Self;
// rhs is the "right-hand side" of the expression `a ^ b`
fn bitxor(self, rhs: Self) -> Self::Output {
Self(self.0 ^ rhs.0)
}
}
assert_eq!(Scalar(true) ^ Scalar(true), Scalar(false));
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 BitXor
trait for a wrapper around Vec<bool>
.
use std::ops::BitXor;
#[derive(Debug, PartialEq)]
struct BooleanVector(Vec<bool>);
impl BitXor for BooleanVector {
type Output = Self;
fn bitxor(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![false, true, true, false]);
assert_eq!(bv1 ^ bv2, expected);
Required Associated Types§
Required Methods§
Implementors§
1.74.0 · Source§impl BitXor for Saturating<i8>
impl BitXor for Saturating<i8>
type Output = Saturating<i8>
1.74.0 · Source§impl BitXor for Saturating<i16>
impl BitXor for Saturating<i16>
type Output = Saturating<i16>
1.74.0 · Source§impl BitXor for Saturating<i32>
impl BitXor for Saturating<i32>
type Output = Saturating<i32>
1.74.0 · Source§impl BitXor for Saturating<i64>
impl BitXor for Saturating<i64>
type Output = Saturating<i64>
1.74.0 · Source§impl BitXor for Saturating<i128>
impl BitXor for Saturating<i128>
type Output = Saturating<i128>
1.74.0 · Source§impl BitXor for Saturating<isize>
impl BitXor for Saturating<isize>
type Output = Saturating<isize>
1.74.0 · Source§impl BitXor for Saturating<u8>
impl BitXor for Saturating<u8>
type Output = Saturating<u8>
1.74.0 · Source§impl BitXor for Saturating<u16>
impl BitXor for Saturating<u16>
type Output = Saturating<u16>
1.74.0 · Source§impl BitXor for Saturating<u32>
impl BitXor for Saturating<u32>
type Output = Saturating<u32>
1.74.0 · Source§impl BitXor for Saturating<u64>
impl BitXor for Saturating<u64>
type Output = Saturating<u64>
1.74.0 · Source§impl BitXor for Saturating<u128>
impl BitXor for Saturating<u128>
type Output = Saturating<u128>
1.74.0 · Source§impl BitXor for Saturating<usize>
impl BitXor for Saturating<usize>
type Output = Saturating<usize>
Source§impl BitXor for PackedNull
impl BitXor for PackedNull
type Output = PackedNull
Source§impl BitXor for StaticVarApiFlags
impl BitXor for StaticVarApiFlags
type Output = StaticVarApiFlags
Source§impl BitXor for CipherCtxFlags
impl BitXor for CipherCtxFlags
type Output = CipherCtxFlags
Source§impl BitXor for CMSOptions
impl BitXor for CMSOptions
type Output = CMSOptions
Source§impl BitXor for Pkcs7Flags
impl BitXor for Pkcs7Flags
type Output = Pkcs7Flags
Source§impl BitXor for ExtensionContext
impl BitXor for ExtensionContext
type Output = ExtensionContext
Source§impl BitXor for ShutdownState
impl BitXor for ShutdownState
type Output = ShutdownState
Source§impl BitXor for SslOptions
impl BitXor for SslOptions
type Output = SslOptions
Source§impl BitXor for SslSessionCacheMode
impl BitXor for SslSessionCacheMode
type Output = SslSessionCacheMode
Source§impl BitXor for SslVerifyMode
impl BitXor for SslVerifyMode
type Output = SslVerifyMode
Source§impl BitXor for X509CheckFlags
impl BitXor for X509CheckFlags
type Output = X509CheckFlags
Source§impl BitXor for X509VerifyFlags
impl BitXor for X509VerifyFlags
type Output = X509VerifyFlags
Source§impl BitXor for WasmFeatures
impl BitXor for WasmFeatures
type Output = WasmFeatures
Source§impl BitXor for SegmentFlags
impl BitXor for SegmentFlags
type Output = SegmentFlags
Source§impl BitXor for SymbolFlags
impl BitXor for SymbolFlags
type Output = SymbolFlags
Source§impl BitXor for CodeMetadata
impl BitXor for CodeMetadata
type Output = CodeMetadata
Source§impl BitXor for EsdtLocalRoleFlags
impl BitXor for EsdtLocalRoleFlags
type Output = EsdtLocalRoleFlags
1.74.0 · Source§impl BitXor<&Saturating<i8>> for &Saturating<i8>
impl BitXor<&Saturating<i8>> for &Saturating<i8>
1.74.0 · Source§impl BitXor<&Saturating<i8>> for Saturating<i8>
impl BitXor<&Saturating<i8>> for Saturating<i8>
1.74.0 · Source§impl BitXor<&Saturating<i16>> for &Saturating<i16>
impl BitXor<&Saturating<i16>> for &Saturating<i16>
1.74.0 · Source§impl BitXor<&Saturating<i16>> for Saturating<i16>
impl BitXor<&Saturating<i16>> for Saturating<i16>
1.74.0 · Source§impl BitXor<&Saturating<i32>> for &Saturating<i32>
impl BitXor<&Saturating<i32>> for &Saturating<i32>
1.74.0 · Source§impl BitXor<&Saturating<i32>> for Saturating<i32>
impl BitXor<&Saturating<i32>> for Saturating<i32>
1.74.0 · Source§impl BitXor<&Saturating<i64>> for &Saturating<i64>
impl BitXor<&Saturating<i64>> for &Saturating<i64>
1.74.0 · Source§impl BitXor<&Saturating<i64>> for Saturating<i64>
impl BitXor<&Saturating<i64>> for Saturating<i64>
1.74.0 · Source§impl BitXor<&Saturating<i128>> for &Saturating<i128>
impl BitXor<&Saturating<i128>> for &Saturating<i128>
1.74.0 · Source§impl BitXor<&Saturating<i128>> for Saturating<i128>
impl BitXor<&Saturating<i128>> for Saturating<i128>
1.74.0 · Source§impl BitXor<&Saturating<isize>> for &Saturating<isize>
impl BitXor<&Saturating<isize>> for &Saturating<isize>
1.74.0 · Source§impl BitXor<&Saturating<isize>> for Saturating<isize>
impl BitXor<&Saturating<isize>> for Saturating<isize>
1.74.0 · Source§impl BitXor<&Saturating<u8>> for &Saturating<u8>
impl BitXor<&Saturating<u8>> for &Saturating<u8>
1.74.0 · Source§impl BitXor<&Saturating<u8>> for Saturating<u8>
impl BitXor<&Saturating<u8>> for Saturating<u8>
1.74.0 · Source§impl BitXor<&Saturating<u16>> for &Saturating<u16>
impl BitXor<&Saturating<u16>> for &Saturating<u16>
1.74.0 · Source§impl BitXor<&Saturating<u16>> for Saturating<u16>
impl BitXor<&Saturating<u16>> for Saturating<u16>
1.74.0 · Source§impl BitXor<&Saturating<u32>> for &Saturating<u32>
impl BitXor<&Saturating<u32>> for &Saturating<u32>
1.74.0 · Source§impl BitXor<&Saturating<u32>> for Saturating<u32>
impl BitXor<&Saturating<u32>> for Saturating<u32>
1.74.0 · Source§impl BitXor<&Saturating<u64>> for &Saturating<u64>
impl BitXor<&Saturating<u64>> for &Saturating<u64>
1.74.0 · Source§impl BitXor<&Saturating<u64>> for Saturating<u64>
impl BitXor<&Saturating<u64>> for Saturating<u64>
1.74.0 · Source§impl BitXor<&Saturating<u128>> for &Saturating<u128>
impl BitXor<&Saturating<u128>> for &Saturating<u128>
1.74.0 · Source§impl BitXor<&Saturating<u128>> for Saturating<u128>
impl BitXor<&Saturating<u128>> for Saturating<u128>
1.74.0 · Source§impl BitXor<&Saturating<usize>> for &Saturating<usize>
impl BitXor<&Saturating<usize>> for &Saturating<usize>
1.74.0 · Source§impl BitXor<&Saturating<usize>> for Saturating<usize>
impl BitXor<&Saturating<usize>> for Saturating<usize>
Source§impl BitXor<&BigUint> for &multiversx_sc_snippets::imports::RustBigUint
impl BitXor<&BigUint> for &multiversx_sc_snippets::imports::RustBigUint
Source§impl BitXor<&BigUint> for multiversx_sc_snippets::imports::RustBigUint
impl BitXor<&BigUint> for multiversx_sc_snippets::imports::RustBigUint
Source§impl BitXor<BigUint> for &multiversx_sc_snippets::imports::RustBigUint
impl BitXor<BigUint> for &multiversx_sc_snippets::imports::RustBigUint
1.74.0 · Source§impl<'a> BitXor<Saturating<i8>> for &'a Saturating<i8>
impl<'a> BitXor<Saturating<i8>> for &'a Saturating<i8>
1.74.0 · Source§impl<'a> BitXor<Saturating<i16>> for &'a Saturating<i16>
impl<'a> BitXor<Saturating<i16>> for &'a Saturating<i16>
1.74.0 · Source§impl<'a> BitXor<Saturating<i32>> for &'a Saturating<i32>
impl<'a> BitXor<Saturating<i32>> for &'a Saturating<i32>
1.74.0 · Source§impl<'a> BitXor<Saturating<i64>> for &'a Saturating<i64>
impl<'a> BitXor<Saturating<i64>> for &'a Saturating<i64>
1.74.0 · Source§impl<'a> BitXor<Saturating<i128>> for &'a Saturating<i128>
impl<'a> BitXor<Saturating<i128>> for &'a Saturating<i128>
1.74.0 · Source§impl<'a> BitXor<Saturating<isize>> for &'a Saturating<isize>
impl<'a> BitXor<Saturating<isize>> for &'a Saturating<isize>
1.74.0 · Source§impl<'a> BitXor<Saturating<u8>> for &'a Saturating<u8>
impl<'a> BitXor<Saturating<u8>> for &'a Saturating<u8>
1.74.0 · Source§impl<'a> BitXor<Saturating<u16>> for &'a Saturating<u16>
impl<'a> BitXor<Saturating<u16>> for &'a Saturating<u16>
1.74.0 · Source§impl<'a> BitXor<Saturating<u32>> for &'a Saturating<u32>
impl<'a> BitXor<Saturating<u32>> for &'a Saturating<u32>
1.74.0 · Source§impl<'a> BitXor<Saturating<u64>> for &'a Saturating<u64>
impl<'a> BitXor<Saturating<u64>> for &'a Saturating<u64>
1.74.0 · Source§impl<'a> BitXor<Saturating<u128>> for &'a Saturating<u128>
impl<'a> BitXor<Saturating<u128>> for &'a Saturating<u128>
1.74.0 · Source§impl<'a> BitXor<Saturating<usize>> for &'a Saturating<usize>
impl<'a> BitXor<Saturating<usize>> for &'a Saturating<usize>
Source§impl<'a, 'b, M> BitXor<&'b BigUint<M>> for &'a multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
impl<'a, 'b, M> BitXor<&'b BigUint<M>> for &'a multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
Source§impl<'a, M> BitXor<u32> for &'a multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
impl<'a, M> BitXor<u32> for &'a multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
Source§impl<'a, M> BitXor<u64> for &'a multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
impl<'a, M> BitXor<u64> for &'a multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
Source§impl<'b, M> BitXor<&'b BigUint<M>> for multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
impl<'b, M> BitXor<&'b BigUint<M>> for multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
Source§impl<M> BitXor for multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
impl<M> BitXor for multiversx_sc_snippets::imports::BigUint<M>where
M: ManagedTypeApi,
Source§impl<Ul, Bl, Ur> BitXor<Ur> for UInt<Ul, Bl>
Xoring unsigned integers.
We use our PrivateXor
operator and then Trim
the output.
impl<Ul, Bl, Ur> BitXor<Ur> for UInt<Ul, Bl>
Xoring unsigned integers.
We use our PrivateXor
operator and then Trim
the output.