You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be better to use this. I'm also confused about the clone-call after args[1], is it related to args[1] returning a reference as opposed to the exact value?
The text was updated successfully, but these errors were encountered:
skade
changed the title
More idiomatic retrievel of command-line args
More idiomatic retrieval of command-line args
Oct 26, 2016
Thanks. The suggested code look like written in more Rust way. I will update my material with it. Also add a explanation of if let, which is a prerequisite to understand this code.
The current slides use this code:
This does unnecessary bounds checking and an allocation of the command line args.
env::args()
is an iterator and already provides positional and crash-safe access to command line arguments:I think it would be better to use this. I'm also confused about the clone-call after
args[1]
, is it related toargs[1]
returning a reference as opposed to the exact value?The text was updated successfully, but these errors were encountered: