How to contruct variable typed std::env::Args?

#1

I tried let args = std::env::Args {inner: ["xxx", "yyy"]}, but not works.

0 Likes

#2

std::env::Args is not something you can construct from your own data, it’s solely to be generated from std::env::args.

It’s unclear what your actual goal is, so if you expand on that we might be able to suggest a solution.

0 Likes

#3

Thanks.I just want to mock std::env::Args to testing.

0 Likes

#4

You might be able to rewrite your code to take impl Iterator<Item=String> instead. Then you can pass in Args normally and a vec::IntoIter<String> when testing.

1 Like

#5

Fine.It works.

0 Likes