Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support argument destructuring for #[values(...)] #231

Closed
nyurik opened this issue Mar 11, 2024 · 2 comments · Fixed by #268
Closed

Support argument destructuring for #[values(...)] #231

nyurik opened this issue Mar 11, 2024 · 2 comments · Fixed by #268

Comments

@nyurik
Copy link

nyurik commented Mar 11, 2024

In some cases, it may be good to combine #[values(...)] and #[cases(...)] approach - e.g. when a certain combination of parameters must be given together.

This code already works, and will execute 4 times (since both params are given as having two possible values). The second parameter's tuple will always be used together:

#[rstest]
fn my_tester(
    #[values(1, 2)] param1: i32,
    #[values(('x', "xxx"), ('y', "yyy"))] param2: (char, &'static str),
) {
  let (param2a, param2b) = param2;  // destructure second param into its components
  ...
}

Proposal

Support param destructuring in the fn declaration:

#[rstest]
fn my_tester(
    #[values(1, 2)] param1: i32,
    #[values(('x', "xxx"), ('y', "yyy"))] (param2a, param2b): (char, &'static str),
) {
  ...
}
@la10736
Copy link
Owner

la10736 commented Mar 11, 2024

Yeah, I've planned the support for destructuring both for values, case and fixture. But I cannot estimate when I'll do t.

@la10736
Copy link
Owner

la10736 commented Aug 4, 2024

Done

@la10736 la10736 closed this as completed Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants