state_shift

Attribute Macro require

source
#[require]
Expand description

Denotes which state is required for this method to be called.

Usage:

  • #[require(State1)]
  • or with multiple state slots: #[require(State1, State2, ...)]

What it does:

  • generates a specific impl block for the method,
  • adds the required types and generics to the impl block,
  • adds the hidden _state field to the Self { } struct, so you don’t have to worry about anything regarding type-state-pattern,
  • to be able to do all these, it needs to know the name of the struct.

To save the users of this library from having to provide the name of the struct to each #[require] macro, #[states] macro handles that for you, providing the name of the struct to the #[require] macro behind the scenes.