require

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, ...)]

This macro is consumed by the #[impl_state] macro, and it basically guides #[impl_state] macro to:

  • generate a specific impl block for each method,
  • add the required types and generics to the generated impl blocks,
  • add the hidden _state field to the Self { } struct, so you don’t have to worry about anything regarding type-state-pattern

hence, it is empty, because it delegates its job to #[impl_state] macro the reason for that delegation is: #[require] macro needs the below from the encapsulating impl block for the methods

  • name of the impl block (name of the struct)
  • generics
  • lifetimes