[][src]Trait smart_access::BatchRt

#[must_use]pub trait BatchRt<View: ?Sized, R>: Batch<R> {
    fn add<G>(self, g: G) -> Self
    where
        G: FnOnce(&mut View, Option<R>) -> R + 'static
;
fn clear(self) -> Self;
fn pop(
        self,
        dst: Option<&mut Option<Box<dyn FnOnce(&mut View, Option<R>) -> R>>>
    ) -> Self;
fn edit(&mut self) -> &mut Vec<Box<dyn FnOnce(&mut View, Option<R>) -> R>>; fn run(self) -> Option<R> { ... } }

A runtime batch. Requires batch_rt feature.

See basic usage guide here.

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

use smart_access::{ BatchRt, Cps };

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

let mut foo = 1;

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

Required methods

fn add<G>(self, g: G) -> Self where
    G: FnOnce(&mut View, Option<R>) -> R + 'static, 

Adds a new function to a runtime batch.

fn clear(self) -> Self

Clears a runtime batch.

fn pop(
    self,
    dst: Option<&mut Option<Box<dyn FnOnce(&mut View, Option<R>) -> R>>>
) -> Self

Takes the last function from a runtime batch.

fn edit(&mut self) -> &mut Vec<Box<dyn FnOnce(&mut View, Option<R>) -> R>>

A direct access to the underlying vector.

Loading content...

Provided methods

fn run(self) -> Option<R>

Runs a runtime batch.

Loading content...

Implementors

impl<CPS: Cps, R> BatchRt<<CPS as Cps>::View, R> for CpsBatch<CPS, Vec<Box<dyn FnOnce(&mut CPS::View, Option<R>) -> R>>>[src]

Loading content...