macro_rules! id {
($world:ident) => { ... };
($world:ident [$rank:expr_2021]) => { ... };
($world:ident [$rank:expr_2021] . $actor:ident) => { ... };
($world:ident [$rank:expr_2021] . $actor:ident [$pid:expr_2021]) => { ... };
($world:ident . $actor:ident) => { ... };
($world:ident [$rank:expr_2021] . $actor:ident [$pid:expr_2021] [$port:expr_2021]) => { ... };
}
Expand description
Statically create a WorldId
, ProcId
, ActorId
or GangId
,
given the concrete syntax documented in Reference
:
assert_eq!(id!(hello), WorldId("hello".into()));
assert_eq!(id!(hello[0]), ProcId::Ranked(WorldId("hello".into()), 0));
assert_eq!(
id!(hello[0].actor),
ActorId(
ProcId::Ranked(WorldId("hello".into()), 0),
"actor".into(),
0
)
);
assert_eq!(
id!(hello[0].actor[1]),
ActorId(
ProcId::Ranked(WorldId("hello".into()), 0),
"actor".into(),
1
)
);
assert_eq!(
id!(hello.actor),
GangId(WorldId("hello".into()), "actor".into())
);
Prefer to use the id macro to construct identifiers in code, as it guarantees static validity, and preserves and reinforces the uniform concrete syntax of identifiers throughout.