-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the "Parsing command-line arguments" chapter
Make each example runnable without any warnings: add a `println` statement that also provides immediate feedback, instead of using `allow(unused)` attributes that are hidden from the reader. Also, move the explanation on passing arguments when using `cargo run` up to the first example, enabling beginners to run each code iteration, instead of only the final code. Remove the exercise that doesn't make sense anymore.
- Loading branch information
Showing
4 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#![allow(unused)] | ||
|
||
fn main() { | ||
let pattern = std::env::args().nth(1).expect("no pattern given"); | ||
let path = std::env::args().nth(2).expect("no path given"); | ||
|
||
println!("pattern: {:?}, path: {:?}", pattern, path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters