macro_rules! globals { ( __internal, $ctx:ty, $(#[$attr:meta])* ($($vis:tt)?) enum $N:ident { $($var:ident($f:ty)),+ $(,)? } ) => { ... }; ( type ClientContext = $ctx:ty; $(#[$attr:meta])* pub enum $N:ident { $($var:ident($f:ty)),+ $(,)? } ) => { ... }; ( type ClientContext = $ctx:ty; $(#[$attr:meta])* enum $N:ident { $($var:ident($f:ty)),+ $(,)? } ) => { ... }; }
Expand description
Generate a corresponding Objects enum from a Globals enum.
Example
globals! {
type ClientContext = ClientContext;
#[derive(Debug)]
pub enum Globals {
Display(wl_server::objects::Display),
Registry(wl_server::objects::Registry),
}
}
The name Globals
and Objects
can be changed.
This will generate a From<Variant> for Globals
for each of the variants of
Globals
. And for each global, a From<Global::Object> for Objects
will be
generated.
Objects
will be filled with variants from Global::Object
for each of the
globals. It can also contain extra variants, for object types that aren’t
associated with a particular global.