frondeus / frondeus/test-case

Iterable args: a way to expand a given argument of `test_matrix`

Open
#142 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
633
Forks
42
PR merge metrics
No merged PRs in 30d

Description

I'd like to be able to
```rust
fn things() -> Vec { .. }

#[test_matrix([false,true], things())]
fn my_func(a: bool, b: T) { .. }
```
(meaning: expand `things()` into its values, like the literal list to the left).
Today this doesn't compile, saying that `b`'s type doesn't match `things()` (and that's expected).

How do you think this can be solved?
* should we allow this IFF `things()` returns `impl IntoIterator`?
* should we allow a modifier on arguments to mark these to interpret as iterators?
```rust
#[test_matrix([false,true], from: things())]
fn my_func(a: bool, b: T) { .. }
```
```rust
// How about a prelude providing say `iter(..)`
#[test_matrix([false,true], iter(things()))]
fn my_func(a: bool, b: T) { .. }
```
* is there a `const` restriction on `things()`?

BTW could you merge `test_matrix`'s wiki this repo's? There's a new page as well as other modifications
https://github.com/frondeus/test-case/pull/128#issuecomment-1654672811

Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.