diff options
Diffstat (limited to 'incria/src/lib.rs')
-rw-r--r-- | incria/src/lib.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/incria/src/lib.rs b/incria/src/lib.rs index 24fa23d..6acae57 100644 --- a/incria/src/lib.rs +++ b/incria/src/lib.rs @@ -1,4 +1,8 @@ -#![feature(async_fn_in_trait, thread_id_value)] +#![feature( + async_fn_in_trait, + thread_id_value, + return_position_impl_trait_in_trait +)] /*! Incria is a library for incremental computation. It lets you record what a calculation depends on and then only re-run that calculation once one of those dependencies has changed. @@ -39,8 +43,9 @@ To memoise computations, you can normally use a [`ThunkMapper`](`self::thunk::Th This memoises a given 'thunk', which is simply a function with one input, one output, and that is pure except for its use of other mappers. ```rust -# use incria::{thunk::{Thunk, ThunkMapper}, Mapper}; +use incria::{thunk::{Thunk, ThunkMapper}, Mapper}; # use std::{future::Future, pin::Pin}; +#[derive(Default)] struct ExampleThunk; impl Thunk<usize, usize> for ExampleThunk { fn compute(&self, key: usize) -> Pin<Box<dyn Future<Output = usize> + Send + '_>> { @@ -52,7 +57,7 @@ impl Thunk<usize, usize> for ExampleThunk { type ExampleMapper = ThunkMapper<usize, usize, ExampleThunk>; # async fn example() { -assert_eq!(*ExampleMapper::new(ExampleThunk).get(&1).await, 1); +assert_eq!(*ExampleMapper::default().get(&1).await, 1); # } ``` @@ -65,6 +70,7 @@ Normally, you will keep track of dependency IDs alongside some other information */ pub mod deps; +mod lazy_mapping; mod mapping; pub mod thunk; |