rust-cli / book

Documentation on how to use the Rust Programming Language to develop commandline applications
https://rust-cli.github.io/book/index.html
MIT License
816 stars 108 forks source link

Improve code examples in args parsing chapter #231

Closed stomar closed 10 months ago

stomar commented 10 months ago

This adds more context to some examples in the "Parsing command line arguments" chapter.

stomar commented 10 months ago

E.g. instead of

let pattern = std::env::args().nth(1).expect("no pattern given");
let path = std::env::args().nth(2).expect("no path given");

now

fn main() {
    let pattern = std::env::args().nth(1).expect("no pattern given");
    let path = std::env::args().nth(2).expect("no path given");
}

This might help Rust beginners (like myself).