Event

Derive Macro Event 

Source
#[derive(Event)]
{
    // Attributes available to this derive:
    #[esrc]
}
Expand description

Derive an Event implementation, with optional custom naming.

This defines the Event’s name as the name of the derived type, minus the “Event” suffix (if present), unless attributes are specified:

  • esrc(event(name)) will override the name to the value specified. This is equivalent to implementing the trait manually.
  • esrc(event(keep_suffix)) will not remove an “Event” suffix that is present on the type name.

§Example


#[derive(Event)]
#[esrc(event(name = "BazEvent"))]
struct FooEvent;

#[derive(Event)]
struct BarEvent;

print!("{}", FooEvent::name()); // "BazEvent"
print!("{}", BarEvent::name()); // "Bar"