Browse Source

Added NotFoundError and EmptyError

Lorenz Bung 7 years ago
parent
commit
335723f68b
1 changed files with 6 additions and 21 deletions
  1. 6
    21
      hw9/task1/src/lib.rs

+ 6
- 21
hw9/task1/src/lib.rs View File

7
             match str.next() {
7
             match str.next() {
8
                 Some("STAGE") => {
8
                 Some("STAGE") => {
9
                     let msg = m[6..].trim_left();
9
                     let msg = m[6..].trim_left();
10
-
11
-                    /* let mut msg = String::new();
12
-                    while let Some(sub_msg) = s.next() {
13
-                        msg += " ";
14
-                        msg += sub_msg
15
-                    }*/
16
                     Command::Stage(msg.to_string())
10
                     Command::Stage(msg.to_string())
17
                 }
11
                 }
18
                 Some("CONTROL") => {
12
                 Some("CONTROL") => {
19
                     let cmd = m[8..].trim_left();
13
                     let cmd = m[8..].trim_left();
20
-
21
-                    /*let mut cmd = String::new();
22
-                    while let Some(sub_cmd) = s.next() {
23
-                        cmd += " ";
24
-                        cmd += sub_cmd
25
-                    }*/
26
                     Command::Control(cmd.to_string())
14
                     Command::Control(cmd.to_string())
27
                 }
15
                 }
28
-                Some("RETRIEVE") => {
29
-                    Command::Retrieve
30
-                }
31
-                Some(_) => {
32
-                    Command::Error
33
-                }
34
-                None => panic!("Parse Error")
16
+                Some("RETRIEVE") => { Command::Retrieve }
17
+                Some(_) => { Command::NotFoundError }
18
+                None => { Command::EmptyError }
35
             }
19
             }
36
         }
20
         }
37
-        None => panic!("Parse Error!")
21
+        None => { Command::EmptyError }
38
     }
22
     }
39
 }
23
 }
40
 
24
 
42
     Stage(String),
26
     Stage(String),
43
     Control(String),
27
     Control(String),
44
     Retrieve,
28
     Retrieve,
45
-    Error,
29
+    NotFoundError,
30
+    EmptyError,
46
 }
31
 }

Loading…
Cancel
Save