cucumber::try_destructure! [] [src]

macro_rules! try_destructure {
    ($r: ident) => { ... };
}

Destructure a vector of InvokeArgument into a tuple of values, or a bad InvokeResponse, similar to normal try!

Will either short circult return an InvokeArgument::Fail, describing either improper arg count or improper arg type, or will yield the tuple of values

Reminder: Tuple of one value is represented as (t,): (Type,)

Example

#[macro_use]
extern crate cucumber;

use cucumber::{
  InvokeArgument,
  InvokeResponse
};

fn main() {
  fn do_work() -> InvokeResponse {
    let args = vec![
      InvokeArgument::from_str("1"),
      InvokeArgument::from_str("2"),
      InvokeArgument::None
    ];
    let (x, y, z): (u32, u32, bool) = try_destructure!(args);

    if x == 1 && y == 2 && z == false {
      InvokeResponse::Success
    } else {
      InvokeResponse::fail_from_str("Values did not match")
    }
  }
}