|
| 1 | +diff --git a/src/main.rs b/src/main.rs // {{CONTEXT}} |
| 2 | +index 8a23456..9b78901 100644 |
| 3 | +--- a/src/main.rs |
| 4 | ++++ b/src/main.rs |
| 5 | +@@ -10,7 +10,7 @@ fn main() { // {{CONTEXT}} |
| 6 | + println!("Hello, world!"); |
| 7 | + |
| 8 | + // Initialize configuration |
| 9 | +- let config = Config::new(); |
| 10 | ++ let config = Config::new_with_defaults(); |
| 11 | + |
| 12 | + let args = std::env::args().collect::<Vec<String>>(); // {{CURSOR}} |
| 13 | + |
| 14 | +@@ -25,6 +25,8 @@ fn main() { |
| 15 | + // Process command line arguments |
| 16 | + let mut processor = ArgProcessor::new(&args); |
| 17 | + processor.process(); |
| 18 | ++ |
| 19 | ++ println!("Configuration loaded successfully"); |
| 20 | + |
| 21 | + if args.len() > 1 { |
| 22 | + println!("Arguments provided: {}", args.len() - 1); |
| 23 | +@@ -45,9 +47,7 @@ fn process_file(path: &str) -> Result<(), Error> { |
| 24 | + let file = File::open(path)?; |
| 25 | + let reader = BufReader::new(file); |
| 26 | + |
| 27 | +- for line in reader.lines() { |
| 28 | +- println!("{}", line?); |
| 29 | +- } |
| 30 | ++ reader.lines().for_each(|line| println!("{}", line.unwrap_or_default())); |
| 31 | + |
| 32 | + Ok(()) |
| 33 | + } |
| 34 | +@@ -78,6 +78,11 @@ impl Config { |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | ++ pub fn new_with_defaults() -> Self { |
| 39 | ++ let mut config = Self::new(); |
| 40 | ++ config.timeout = Some(30); |
| 41 | ++ config |
| 42 | ++ } |
| 43 | ++ |
| 44 | + // Other methods... |
| 45 | + } |
| 46 | + |
0 commit comments