Attribute Macro opimps::impl_ops_lprim [−][src]
#[impl_ops_lprim]
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);