Test the new syntax 'if let'.
[crypto_lab1.git] / lab1_rust / src / end_point.rs
index f69f78e..97104c6 100644 (file)
@@ -299,10 +299,9 @@ impl EndPoint {
 
    fn read(&mut self) -> ReadingResult {
       fn send_error(ep: &mut EndPoint, error_type: packet::ErrorType) {
-         match ep.send(Error(error_type)) {
-            Err(e) => println!("Unable to send error packet: {}", e),
-            Ok(_) => ()
-         };
+         if let Err(e) = ep.send(Error(error_type)) {
+            println!("Unable to send error packet: {}", e)
+         }
       };
 
       self.socket.set_timeout(DEFAULT_TIMEOUT);