I have this error
error: binary operation
|cannot be applied to type&mut u16
With this code,
fn f_op(op: &mut u16) {
    let mut addr: u16 = (op | 0xFFF);
    ..//
}
Solve it change &mut to &
fn f_op(op: & u16) {
But I wonder why I can not use | with &mut, sure there exists a good reason, but someone can explain to me.
Play-Rust
Because the BitOr trait is not implemented for &mut u16.. however, it is for &u16.

As viraptor points out, you could also dereference it with:
*op | 0xFFF;
.. which would make it a u16.. which also implements the BitOr trait as you can see above.
You probably want to or the value, not the reference.
let mut addr: u16 = *op | 0xFFF;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With