Attribute Macro opimps::impl_ops_lprim
source · #[impl_ops_lprim]
Expand description
Implements the permutations of owned and borrowed data, with self
being a
primitive value and rhs
being a structure.
use std::ops::Mul;
pub struct ANumber {
val: i32
}
#[opimps::impl_ops_lprim(Mul)]
fn mul(self: i32, rhs: ANumber) -> i32 {
return self * rhs.val;
}
let a = 7;
let b = ANumber { val: 4 };
assert_eq!(28, a * &b);
assert_eq!(28, a * b);