this example now runs out of the box instead of failing with no value or the wrong value (#3067)

This commit is contained in:
Michael Angerman 2021-02-19 00:40:53 -08:00 committed by GitHub
parent 7dc1d6a350
commit fc59c87606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,9 +3,18 @@ use std::collections::HashMap;
fn main() {
let args: Vec<_> = std::env::args().collect();
let mut width = 0;
if args.len() > 1 {
// Width in terminal characters
width = args[1].parse::<usize>().expect("Need a width in columns");
}
if width < 4 {
println!("Width must be greater than or equal to 4, setting width to 80");
width = 80;
}
// Width in terminal characters
let width = args[1].parse::<usize>().expect("Need a width in columns");
// The mocked up table data
let (table_headers, row_data) = make_table_data();
// The table headers