diff options
author | tom barrett <spalf0@gmail.com> | 2018-06-28 04:00:48 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2018-06-28 04:00:48 -0500 |
commit | 828f0d83dcb258a8e5efd55a7775592c6e5f77bc (patch) | |
tree | d99dfba7357a5e2cbf8162fe037f2f0fd5a87482 /src/client | |
parent | ae79327d4f0ee6de0ef6b8e3c51299aebfe3bc25 (diff) |
-moved over it if let from bad matches
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/dashboard.rs | 11 | ||||
-rw-r--r-- | src/client/engines.rs | 19 | ||||
-rw-r--r-- | src/client/mining.rs | 19 | ||||
-rw-r--r-- | src/client/navigation.rs | 29 | ||||
-rw-r--r-- | src/client/refinery.rs | 19 |
5 files changed, 41 insertions, 56 deletions
diff --git a/src/client/dashboard.rs b/src/client/dashboard.rs index cbc55ba..5815ee2 100644 --- a/src/client/dashboard.rs +++ b/src/client/dashboard.rs @@ -23,14 +23,11 @@ pub fn client_dashboard(mut buff_r : BufReader<TcpStream>) { termion::cursor::Goto(1,1), ship).unwrap(); - match stdin.next() { - Some(c) => { - let c = c.unwrap() as char; - if c == 'q' { - break; - } + if let Some(c) = stdin.next() { + let c = c.unwrap() as char; + if c == 'q' { + break; } - None => (), } stdout.flush().unwrap(); } diff --git a/src/client/engines.rs b/src/client/engines.rs index 6c6b384..9b2d314 100644 --- a/src/client/engines.rs +++ b/src/client/engines.rs @@ -30,18 +30,15 @@ pub fn client_engines(mut stream : TcpStream, mut buff_r : BufReader<TcpStream>) write!(stdout, "{}t : accelerate torwards target", termion::cursor::Goto(1, 7)).unwrap(); } - match stdin.next() { - Some(c) => { - let c = c.unwrap(); - let mut send = String::new(); - send.push(c as char); - if send.as_bytes() == b"q" { - break; - } - send.push_str("\n"); - stream.write(send.as_bytes()).unwrap(); + if let Some(c) = stdin.next() { + let c = c.unwrap(); + let mut send = String::new(); + send.push(c as char); + if send.as_bytes() == b"q" { + break; } - None => () + send.push_str("\n"); + stream.write(send.as_bytes()).unwrap(); } stdout.flush().unwrap(); diff --git a/src/client/mining.rs b/src/client/mining.rs index 80cd611..221f7ce 100644 --- a/src/client/mining.rs +++ b/src/client/mining.rs @@ -38,18 +38,15 @@ pub fn client_mining(mut stream : TcpStream, mut buff_r : BufReader<TcpStream>) false => write!(stdout, "{}Ship has no astroid targeted.", clear).unwrap(), } - match stdin.next() { - Some(c) => { - let c = c.unwrap(); - let mut send = String::new(); - send.push(c as char); - if send.as_bytes() == b"q" { - break; - } - send.push_str("\n"); - stream.write(send.as_bytes()).unwrap(); + if let Some(c) = stdin.next() { + let c = c.unwrap(); + let mut send = String::new(); + send.push(c as char); + if send.as_bytes() == b"q" { + break; } - None => () + send.push_str("\n"); + stream.write(send.as_bytes()).unwrap(); } stdout.flush().unwrap(); diff --git a/src/client/navigation.rs b/src/client/navigation.rs index 9bc13f9..34e1b7a 100644 --- a/src/client/navigation.rs +++ b/src/client/navigation.rs @@ -44,23 +44,20 @@ pub fn client_navigation(name : String, mut stream : TcpStream, mut buff_r : Buf ).unwrap(); } - match stdin.next() { - Some(c) => { - let c = c.unwrap() as char; - if c == 'q' { - break; + if let Some(c) = stdin.next() { + let c = c.unwrap() as char; + if c == 'q' { + break; + } + else { + let i = c.to_digit(10).unwrap() as usize; + if i < within_range.len() { + let mut send = String::new(); + send.push_str(within_range.iter().nth(i).unwrap().0); + send.push_str("\n"); + stream.write(send.as_bytes()).unwrap(); } - else { - let i = c.to_digit(10).unwrap() as usize; - if i < within_range.len() { - let mut send = String::new(); - send.push_str(within_range.iter().nth(i).unwrap().0); - send.push_str("\n"); - stream.write(send.as_bytes()).unwrap(); - } - } - }, - None => (), + } } } stdout.flush().unwrap(); diff --git a/src/client/refinery.rs b/src/client/refinery.rs index 5f126bf..013172d 100644 --- a/src/client/refinery.rs +++ b/src/client/refinery.rs @@ -32,18 +32,15 @@ pub fn client_refinery(mut stream : TcpStream, mut buff_r : BufReader<TcpStream> false => write!(stdout, "{}You have no refinable minerals.", clear).unwrap(), } - match stdin.next() { - Some(c) => { - let c = c.unwrap(); - let mut send = String::new(); - send.push(c as char); - if send.as_bytes() == b"q" { - break; - } - send.push_str("\n"); - stream.write(send.as_bytes()).unwrap(); + if let Some(c) = stdin.next() { + let c = c.unwrap(); + let mut send = String::new(); + send.push(c as char); + if send.as_bytes() == b"q" { + break; } - None => () + send.push_str("\n"); + stream.write(send.as_bytes()).unwrap(); } stdout.flush().unwrap(); |