Browse Source

Corrected output of hw2/task2.Ran run-all.sh.

Joshua Rutschmann 8 years ago
parent
commit
64eedd1db9
1 changed files with 15 additions and 4 deletions
  1. 15
    4
      hw2/task2/src/main.rs

+ 15
- 4
hw2/task2/src/main.rs View File

5
 
5
 
6
 fn main() {
6
 fn main() {
7
     let args = env::args().collect();
7
     let args = env::args().collect();
8
-    print_arguments(&args);
9
 
8
 
9
+    //print_arguments(&args);
10
     //let conf = parse_arguments_simple(&args);
10
     //let conf = parse_arguments_simple(&args);
11
     //let res = parse_arguments(&args);
11
     //let res = parse_arguments(&args);
12
 
12
 
13
     let res = Config::new(&args);
13
     let res = Config::new(&args);
14
     match res {
14
     match res {
15
         Ok(conf) => {
15
         Ok(conf) => {
16
-            println!("{:?}", conf);
17
-            println!("{:?}", task2::run(&conf));
16
+            println!(
17
+                "You asked me to count all '{}' in '{}'",
18
+                conf.search,
19
+                conf.line
20
+            );
21
+            let occ = task2::run(&conf);
22
+            println!("Found {} '{}' in '{}'", occ, conf.search, conf.line);
23
+        }
24
+        Err(message) => {
25
+            println!("{}", message);
26
+            process::exit(1)
18
         }
27
         }
19
-        Err(_) => process::exit(1),
20
     }
28
     }
21
 
29
 
30
+
31
+
22
 }
32
 }
23
 
33
 
24
 /*
34
 /*
78
 /// each line
88
 /// each line
79
 ///
89
 ///
80
 /// Returns nothing
90
 /// Returns nothing
91
+#[allow(dead_code)]
81
 fn print_arguments(args: &Vec<String>) {
92
 fn print_arguments(args: &Vec<String>) {
82
     for s in args {
93
     for s in args {
83
         println!("args found: {}", s);
94
         println!("args found: {}", s);

Loading…
Cancel
Save