pub struct Label {
pub name: &'static str,
pub pid: Option<NonZero<usize>>,
}Expand description
Agent-specific identifier that uniquely identifies an instance over the course of a simulation run.
It renders as a string containing the base name - usually the type name,
but user-definable by setting the name during agent building or by
implementing Behavior::name - followed by a pound symbol and an instance
number, e.g. "JamesBond#7". The name is pretty printed by default but can
be written out by using alternative formatting:
let agent = pin!(Agent::new((Rc::new(MyAgent), MyAgent::actions)));
let puck = sim.activate(agent);
// outputs "Rc<MyAgent>#1"
println!("{}", puck.label());
// outputs "alloc::rc::Rc<lab::MyAgent>#1"
println!("{:#}", puck.label());
Fields§
§name: &'static strThe agent name.
pid: Option<NonZero<usize>>The agent-name-specific ID.
Implementations§
Source§impl Label
impl Label
Sourcepub fn pretty_name(&self) -> impl Iterator<Item = &'static str>
pub fn pretty_name(&self) -> impl Iterator<Item = &'static str>
Returns an iterator of string slices into the agent name that corresponds to a pretty-printed version of the type path.
The implementation is stolen inspired by Jakob Hellermann’s
pretty-type-name crate, adapted to use a heapless iterator rather
than a String.
Trait Implementations§
impl Copy for Label
impl Eq for Label
impl StructuralPartialEq for Label
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Label
impl UnwindSafe for Label
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more