pub struct RevisedProperty<T> { /* private fields */ }
Expand description
Revised property is the cached result of a function call that is only evaluated lazily whenever the inputs have changed, according to their RevisionHash.
Implementations§
Source§impl<T> RevisedProperty<T>
impl<T> RevisedProperty<T>
Sourcepub fn new() -> RevisedProperty<T>
pub fn new() -> RevisedProperty<T>
Create a new RevisedProperty with an empty cache
Sourcepub fn get_cached(&self) -> Option<&T>
pub fn get_cached(&self) -> Option<&T>
Get the cached value, which might not be filled yet. This stores the result of the refresh* method that was most recently called, if any.
Sourcepub fn refresh1<F, A0>(&mut self, f: F, arg0: A0)
pub fn refresh1<F, A0>(&mut self, f: F, arg0: A0)
Update the cache to store the result of calling f(arg0). If the function’s output from the same arguments is already cached, the function is not called and the cache is kept. Otherwise, f is called and the cache is written to. f is assumed to be a pure function.
Sourcepub fn refresh2<F, A0, A1>(&mut self, f: F, arg0: A0, arg1: A1)
pub fn refresh2<F, A0, A1>(&mut self, f: F, arg0: A0, arg1: A1)
Update the cache to store the result of calling f(arg0, arg1). If the function’s output from the same arguments is already cached, the function is not called and the cache is kept. Otherwise, f is called and the cache is written to. f is assumed to be a pure function.
Sourcepub fn refresh3<F, A0, A1, A2>(&mut self, f: F, arg0: A0, arg1: A1, arg2: A2)
pub fn refresh3<F, A0, A1, A2>(&mut self, f: F, arg0: A0, arg1: A1, arg2: A2)
Update the cache to store the result of calling f(arg0, arg1, arg2). If the function’s output from the same arguments is already cached, the function is not called and the cache is kept. Otherwise, f is called and the cache is written to. f is assumed to be a pure function.
Sourcepub fn refresh4<F, A0, A1, A2, A3>(
&mut self,
f: F,
arg0: A0,
arg1: A1,
arg2: A2,
arg3: A3,
)
pub fn refresh4<F, A0, A1, A2, A3>( &mut self, f: F, arg0: A0, arg1: A1, arg2: A2, arg3: A3, )
Update the cache to store the result of calling f(arg0, arg1, arg2, arg3). If the function’s output from the same arguments is already cached, the function is not called and the cache is kept. Otherwise, f is called and the cache is written to. f is assumed to be a pure function.
Sourcepub fn refresh5<F, A0, A1, A2, A3, A4>(
&mut self,
f: F,
arg0: A0,
arg1: A1,
arg2: A2,
arg3: A3,
arg4: A4,
)
pub fn refresh5<F, A0, A1, A2, A3, A4>( &mut self, f: F, arg0: A0, arg1: A1, arg2: A2, arg3: A3, arg4: A4, )
Update the cache to store the result of calling f(arg0, arg1, arg2, arg3, arg4). If the function’s output from the same arguments is already cached, the function is not called and the cache is kept. Otherwise, f is called and the cache is written to. f is assumed to be a pure function.