Struct changed::Cd [−][src]
pub struct Cd<T> { /* fields omitted */ }
Expand description
Cd: Change Detection
Start by creating one with new()
.
Implementations
Create a new Cd with data. It is initialized to false for change detection.
use changed::Cd; let cd = Cd::new(5);
Create a new Cd with data. It is initialized to true for change detection.
use changed::Cd; let cd = Cd::new_true(5); assert!(cd.changed());
Reset the change tracking to false.
use changed::Cd; let mut cd = Cd::new_true(5); cd.reset(); assert!(!cd.changed());
Take the data out of the Cd. Consumes self and returns data.
use changed::Cd; let cd = Cd::new(5); let data = cd.take(); // Error: cd has been moved. // cd.changed();
Check if the Cd has been changed since the last call to reset (or created.)
use changed::Cd; let mut cd = Cd::new(5); assert!(!cd.changed()); *cd += 5; assert!(cd.changed());
Mutate the Cd without tripping change detection.
use changed::Cd; let mut cd = Cd::new(5); *cd.mutate_silently() += 5; assert!(!cd.changed());
Trait Implementations
Impl default where the data impls default. Change detection is initialized to false.
use changed::Cd; // 0 is default for i32. let zero: Cd<i32> = Cd::default(); assert!(!zero.changed());
deref does not trip change detection.
use changed::Cd; let cd = Cd::new(5); assert_eq!(*cd, 5); // deref for == 5 assert!(!cd.changed()); // .changed() is false
Auto Trait Implementations
impl<T> RefUnwindSafe for Cd<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Cd<T> where
T: UnwindSafe,