Lorenz Bung 7 лет назад
Родитель
Сommit
eea960d141
2 измененных файлов: 9 добавлений и 6 удалений
  1. 5
    5
      hw9/task1/src/lib.rs
  2. 4
    1
      hw9/task1/tests/task1.rs

+ 5
- 5
hw9/task1/src/lib.rs Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 pub fn parse(message: &str) -> Command {
2
-    let m : String = String::from(message);
2
+    let m: String = String::from(message);
3 3
     let mut line = m.lines();
4 4
     match line.next() {
5 5
         Some(x) => {
@@ -13,12 +13,12 @@ pub fn parse(message: &str) -> Command {
13 13
                     let cmd = m[8..].trim_left();
14 14
                     Command::Control(cmd.to_string())
15 15
                 }
16
-                Some("RETRIEVE") => { Command::Retrieve }
17
-                Some(_) => { Command::Error(ParseError::UnknownCommand) }
18
-                None => { Command::Error(ParseError::EmptyString) }
16
+                Some("RETRIEVE") => Command::Retrieve,
17
+                Some(_) => Command::Error(ParseError::UnknownCommand),
18
+                None => Command::Error(ParseError::EmptyString),
19 19
             }
20 20
         }
21
-        None => { Command::Error(ParseError::EmptyString) }
21
+        None => Command::Error(ParseError::EmptyString),
22 22
     }
23 23
 }
24 24
 

+ 4
- 1
hw9/task1/tests/task1.rs Просмотреть файл

@@ -25,7 +25,10 @@ mod tests {
25 25
 
26 26
     #[test]
27 27
     fn control_returns_correct_command() {
28
-        assert_eq!(parse("CONTROL Hello"), Command::Control("Hello".to_string()))
28
+        assert_eq!(
29
+            parse("CONTROL Hello"),
30
+            Command::Control("Hello".to_string())
31
+        )
29 32
     }
30 33
 
31 34
     #[test]

Загрузка…
Отмена
Сохранить