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

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

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.

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

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.


Fine.It works.