Skip to content

Iterable args: a way to expand a given argument of test_matrix #142

@fenollp

Description

@fenollp

I'd like to be able to

fn things() -> Vec<T> { .. }

#[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<Item = T>?
  • should we allow a modifier on arguments to mark these to interpret as iterators?
#[test_matrix([false,true], from: things())]
fn my_func(a: bool, b: T) { .. } 
// 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
#128 (comment)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions