From cce7f6266d2da76c6e70344c3cf492a5f89d9ff7 Mon Sep 17 00:00:00 2001 From: Joey Eamigh <55670930+JoeyEamigh@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:44:12 -0500 Subject: [PATCH] fixing newline issue --- src/main.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0bfa62f..03f51d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,17 +27,16 @@ async fn main() { let mut location_id: u32 = CHARLOTTE; let mut buf = [0, 0, 0, 0]; - println!("Enter a location id to override the default (Charlotte, NC): "); - let loc_input = io::stdin().read(&mut buf).await; + println!( + "Enter a location id to override the default (Charlotte, NC, {:?}): ", + CHARLOTTE + ); + io::stdin().read(&mut buf).await.unwrap(); - if loc_input.unwrap() > 1 { - location_id = String::from_utf8(buf.to_vec()) - .unwrap() - .trim() - .parse() - .unwrap(); + let loc = String::from_utf8(buf.to_vec()).unwrap().trim().parse(); + if loc.is_ok() { + location_id = loc.unwrap(); } - eprintln!("Using default location (Charlotte, NC): {}", location_id); println!("Looking for appointments at location id: {}", location_id); loop {