Macro cell_family::define
source · macro_rules! define {
(
$( #[$attr: meta] )*
$vis: vis static type $family_name: ident $(: $owner_ident: ident)? $(for $cell_ident: ident<$t: ident>)?
$( ; $( $rest: tt )* )?
) => { ... };
(
$( #[$attr: meta] )*
$vis: vis unsafe static type $family_name: ident $(: $owner_ident: ident)? $(for $cell_ident: ident<$t: ident>)?
$( ; $( $rest: tt )* )?
) => { ... };
(
$( #[$attr: meta] )*
$vis: vis type $family_name: ident $(: $owner_ident: ident)? $(for $cell_ident: ident<$t: ident>)?
$( ; $( $rest: tt )* )?
) => { ... };
(
$( #[$attr: meta] )*
$vis: vis unsafe type $family_name: ident $(: $owner_ident: ident)? $(for $cell_ident: ident<$t: ident>)?
$( ; $( $rest: tt )* )?
) => { ... };
() => { ... };
}
Expand description
Defines a cell Family
, and optional Cell
and CellOwner
aliases.
Example
Define a family whose CellOwner
s are thread-local:
cell_family::define! {
/// Family for Foos.
pub type FooFamily;
}
Example
Define a family whose CellOwner
s are thread-local, and
define the alias BarCellOwner
for
CellOwner<BarFamily>
and BarCell<B>
for
Cell<BarFamily, B>
:
cell_family::define! {
/// Family for Bars.
pub type BarFamily: BarCellOwner for BarCell<B>;
}
Example
Define a family whose CellOwner
s are global, and
define the alias BazCellOwner
for
CellOwner<BazFamily>
:
cell_family::define! {
/// Family for Bars.
pub static type BazFamily: BazCellOwner;
}
Example
Define a family whose CellOwner
s are global, and
define the alias QuuxCell<T>
for Cell<QuuxFamily, T>
; in
release builds (cfg!(debug_assertions)
is false
), all checks are
disabled, and the cell behaves like an
UnsafeCell<T>
:
cell_family::define! {
/// Family for Quuxes.
pub unsafe static type QuuxFamily for QuuxCell<T>;
}