anchors 0.6.0

async incremental computations
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use anchors::expert::{AnchorExt, Var};
use anchors::singlethread::*;
use std::cell::RefCell;

thread_local! {
    pub static ENGINE: RefCell<Engine> = RefCell::new(Engine::new());
}

fn main() {
    // important to call ENGINE.with before we create any Anchors, since the engine
    // must have been initialized for an anchor to be created.
    ENGINE.with(|engine| {
        let (foo, _set_foo) = Var::new(1);
        let foo_added = foo.map(|n| n + 1);
        println!("{:?}", engine.borrow_mut().get(&foo_added));
    });
}