logo

Derive Macro cucumber::World

source · []
#[derive(World)]
{
    // Attributes available to this derive:
    #[world]
}
Available on crate feature macros only.
Expand description

Derive macro for implementing a World trait.

Example

#[derive(cucumber::World)]
#[world(init = Self::new)] // optional, uses `Default::default()` if omitted
struct World(usize);

impl World {
    fn new() -> Self {
        Self(42)
    }
}

Attribute arguments

  • #[world(init = path::to::fn)]

    Path to a function to be used for a World instance construction. Specified function can be either sync or async, and either fallible (return Result) or infallible (return World itself). In case no function is specified, the Default::default() will be used for construction.