#[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 orasync
, and either fallible (return [Result
]) or infallible (returnWorld
itself). In case no function is specified, the [Default::default()
] will be used for construction.