pub trait RefBitXor<Rhs = Self>: Sealed<Rhs> {
type Output;
// Required method
fn ref_bitxor(&self, rhs: Rhs) -> Self::Output;
}
Expand description
bitxor
operation through references.
As of Rust 1.73.0, the following code does not compile:
ⓘ
use core::ops::BitXor;
struct A<T>(T);
impl<'a, 'b, T, U> BitXor<&'b A<U>> for &'a A<T>
where
&'a T: BitXor<&'b U>,
{
type Output = A<<&'a T as BitXor<&'b U>>::Output>;
fn bitxor(self, rhs: &'b A<U>) -> Self::Output {
A(self.0.bitxor(&rhs.0))
}
}
fn _f<T, U>(a: T, b: U)
where
for<'a, 'b> &'a T: BitXor<&'b U>,
{
let _a_op_b = (&a).bitxor(&b);
// to do something with `a`, `b`, and `_a_op_b`
}
fn _g<T, U>(a: T, b: U)
where
for<'a, 'b> &'a T: BitXor<&'b U>,
{
_f(a, b);
}
but the following code does:
use core::ops::BitXor;
use ref_ops::RefBitXor;
struct A<T>(T);
impl<'a, T, U> BitXor<&'a A<U>> for &A<T>
where
T: RefBitXor<&'a U>,
{
type Output = A<T::Output>;
fn bitxor(self, rhs: &'a A<U>) -> Self::Output {
A(self.0.ref_bitxor(&rhs.0))
}
}
fn _f<T, U>(a: T, b: U)
where
for<'a, 'b> &'a T: BitXor<&'b U>,
{
let _a_op_b = (&a).bitxor(&b);
// to do something with `a`, `b`, and `_a_op_b`
}
fn _g<T, U>(a: T, b: U)
where
for<'a, 'b> &'a T: BitXor<&'b U>,
{
_f(a, b);
}
Required Associated Types§
Required Methods§
Sourcefn ref_bitxor(&self, rhs: Rhs) -> Self::Output
fn ref_bitxor(&self, rhs: Rhs) -> Self::Output
Performs bitxor
operation.