[][src]Function moxie::cache

pub fn cache<Arg: ?Sized, Input, Output>(
    arg: &Arg,
    init: impl FnOnce(&Input) -> Output
) -> Output where
    Arg: PartialEq<Input> + ToOwned<Owned = Input>,
    Input: Borrow<Arg> + 'static,
    Output: Clone + 'static, 

Memoizes init at this callsite, cloning a cached Output if it exists and Input is the same as when the stored value was created.

init takes a reference to Input so that the cache can compare future calls' arguments against the one used to produce the stored value.

Environment Expectations

This function requires the following types to be visible to illicit::get and will panic otherwise: