Skip to main content

param_type

Attribute Macro param_type 

Source
#[param_type]
Expand description

Register a custom parameter type for Cucumber expressions.

Defines a new {name} placeholder that matches the given regex. Use it on a dummy function whose body is discarded — only the attribute arguments matter.

// Simple: defines {color} matching red|green|blue
#[param_type(name = "color", regex = "red|green|blue")]
fn color_type() {}

// Then use in step definitions:
#[given("I pick a {color} item")]
async fn pick(world: &mut BrowserWorld, color: String) {
    // color = "red", "green", or "blue"
}