Argument handling
This commit is contained in:
parent
1bb1d6ba98
commit
80ddb74098
1 changed files with 12 additions and 1 deletions
13
src/main.rs
13
src/main.rs
|
@ -1,7 +1,18 @@
|
|||
const FREQ_TABLE: &[char] = &['f', 'g', 'h', 'j', 'f', 'a', 's', 'd', 'k', 'l', 'g', 'u'];
|
||||
|
||||
fn main() {
|
||||
let len = std::env::args().nth(1).unwrap().parse::<usize>().unwrap();
|
||||
let len: usize = std::env::args()
|
||||
.nth(1)
|
||||
.and_then(|x| {
|
||||
let x = x.parse::<usize>();
|
||||
if x.is_err() {
|
||||
eprintln!("Argument is not a number...");
|
||||
std::process::exit(-1);
|
||||
}
|
||||
Some(x.unwrap())
|
||||
})
|
||||
.or(Some(32))
|
||||
.unwrap();
|
||||
|
||||
let mut last: char = '\0';
|
||||
|
||||
|
|
Loading…
Reference in a new issue