Trait DivAssign
1.8.0 (const: unstable) · Source pub trait DivAssign<Rhs = Self> {
// Required method
fn div_assign(&mut self, rhs: Rhs);
}
Expand description
The division assignment operator /=.
§Examples
use std::ops::DivAssign;
#[derive(Debug, PartialEq)]
struct Frequency { hertz: f64 }
impl DivAssign<f64> for Frequency {
fn div_assign(&mut self, rhs: f64) {
self.hertz /= rhs;
}
}
let mut frequency = Frequency { hertz: 200.0 };
frequency /= 4.0;
assert_eq!(Frequency { hertz: 50.0 }, frequency);
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
Performs the /= operation.
§Example
let mut x: u32 = 12;
x /= 2;
assert_eq!(x, 6);