[][src]Trait smart_access::BatchCt

#[must_use]pub trait BatchCt<V: ?Sized, R>: Batch<R> {
    type CPS: Cps<View = V>;
    type List: RunBatch<V, Output = R>;
    fn add<G, S>(self, g: G) -> CpsBatch<Self::CPS, (Self::List, G)>
    where
        G: FnOnce(&mut V, R) -> S
;
fn clear(self) -> CpsBatch<Self::CPS, ()>; fn run(self) -> Option<R> { ... } }

A compile-time batch. Requires batch_ct feature.

See basic usage guide here.

Allows one to write batch transformers without specifying complex return types.

use smart_access::{ BatchCt, Cps };

fn add_inc<T>(batch: impl BatchCt<i32, T>) -> impl BatchCt<i32, ()>
{
    batch.add(|x, _| { *x = *x + 1; })
}

let mut foo = 1;

add_inc(add_inc(foo.batch_ct())).run();
assert!(foo == 3);

Associated Types

type CPS: Cps<View = V>

type List: RunBatch<V, Output = R>

Loading content...

Required methods

fn add<G, S>(self, g: G) -> CpsBatch<Self::CPS, (Self::List, G)> where
    G: FnOnce(&mut V, R) -> S, 

Adds a new function to a compile-time batch.

fn clear(self) -> CpsBatch<Self::CPS, ()>

Clears a compile-time batch.

Loading content...

Provided methods

fn run(self) -> Option<R>

Runs a compile-time batch.

Loading content...

Implementors

impl<CPS, Prev, F, R> BatchCt<<CPS as Cps>::View, R> for CpsBatch<CPS, (Prev, F)> where
    CPS: Cps,
    (Prev, F): RunBatch<CPS::View, Output = R>, 
[src]

type CPS = CPS

type List = (Prev, F)

impl<CPS: Cps> BatchCt<<CPS as Cps>::View, ()> for CpsBatch<CPS, ()>[src]

type CPS = CPS

type List = ()

Loading content...