Struct fates::fates::Fate [−][src]
pub struct Fate<T: Clone> { /* fields omitted */ }
Implementations
pub fn bind_expression(
&self,
expression: Box<dyn Fn() -> T + Send + Sync + 'static>,
dependencies: Vec<Box<dyn FateTrait>>
)
pub fn from_expression(
expression: Box<dyn Fn() -> T + Send + Sync + 'static>,
dependencies: Vec<Box<dyn FateTrait>>
) -> Fate<T>
Creates a Fate with the same value that depends on this Fate. This can be useful for easily checking when the value has been updated.
Examples
fate! {
let a = 5;
let b = a + 3;
}
let child = b.create_dependent_clone();
assert_eq!(child.get(), 8);
fate! {
a = 10;
}
assert_eq!(b.get(), 13);
assert_eq!(b.is_dirty(), false);
assert_eq!(child.is_dirty(), true);
assert_eq!(child.get(), 13);
assert_eq!(child.is_dirty(), false);
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Fate<T>
impl<T> !UnwindSafe for Fate<T>
Blanket Implementations
Mutably borrows from an owned value. Read more