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