What is the most idiomatic way to match against an iterator's item? For example, if we take command line arguments, what is the best way to use pattern matching on one of the items? This is what I'm doing and I'm not 100% sure why as_ref()
is required and why &args[0]
wouldn't work:
let args: Vec<String> = env::args().skip(1).collect();
match args[0].as_ref() {...}