Struct RevisedProperty

Source
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>

Source

pub fn new() -> RevisedProperty<T>

Create a new RevisedProperty with an empty cache

Source

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.

Source

pub fn refresh1<F, A0>(&mut self, f: F, arg0: A0)
where F: Fn(A0) -> T, A0: Revisable,

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.

Source

pub fn refresh2<F, A0, A1>(&mut self, f: F, arg0: A0, arg1: A1)
where F: Fn(A0, A1) -> T, A0: Revisable, A1: Revisable,

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.

Source

pub fn refresh3<F, A0, A1, A2>(&mut self, f: F, arg0: A0, arg1: A1, arg2: A2)
where F: Fn(A0, A1, A2) -> T, A0: Revisable, A1: Revisable, A2: Revisable,

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.

Source

pub fn refresh4<F, A0, A1, A2, A3>( &mut self, f: F, arg0: A0, arg1: A1, arg2: A2, arg3: A3, )
where F: Fn(A0, A1, A2, A3) -> T, A0: Revisable, A1: Revisable, A2: Revisable, A3: Revisable,

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.

Source

pub fn refresh5<F, A0, A1, A2, A3, A4>( &mut self, f: F, arg0: A0, arg1: A1, arg2: A2, arg3: A3, arg4: A4, )
where F: Fn(A0, A1, A2, A3, A4) -> T, A0: Revisable, A1: Revisable, A2: Revisable, A3: Revisable, A4: Revisable,

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.

Auto Trait Implementations§

§

impl<T> Freeze for RevisedProperty<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for RevisedProperty<T>
where T: RefUnwindSafe,

§

impl<T> Send for RevisedProperty<T>
where T: Send,

§

impl<T> Sync for RevisedProperty<T>
where T: Sync,

§

impl<T> Unpin for RevisedProperty<T>
where T: Unpin,

§

impl<T> UnwindSafe for RevisedProperty<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.