Macro adapton::cell [] [src]

macro_rules! cell {
    ( $value:expr ) => { ... };
    ( [ $nm:expr ] ? $value:expr ) => { ... };
    ( [ $nm:ident ] $value:expr ) => { ... };
}

Convenience wrappers for engine::cell.

Optional-name version

In this verion, supply an expression optional_name of type Option<Name> to specify the name for the cell, created by either cell or put, in the case that optional_name is Some(name) or None, respectively:

let n = name_of_str(stringify!(c));
let c = cell!([Some(n)]? 123);

assert_eq!(get!(c), 123);
assert_eq!(get!(c), force(&c));

let c = cell!([None]? 123);

assert_eq!(get!(c), 123);
assert_eq!(get!(c), force(&c));

Explicit-names version:

In this verion, use [ name ] to specify the cell's name is name:

let c = cell!([c] 123);

assert_eq!(get!(c), 123);
assert_eq!(get!(c), force(&c));

Global counter version:

Uses a global counter to choose a unique name. Important note: This may be appopriate for the Editor role, but is never appropriate for the Archivist role.

let c = cell!( 123 );

assert_eq!( get!(c), 123 );
assert_eq!( get!(c), force(&c) );