# HG changeset patch # User Emmanuel Gil Peyrot # Date 1605818160 -3600 # Node ID 4adea0a8c8dde0a33ff9713825ff2deb2e2c3afb # Parent 57b200fad67ee37241efd30499757d1bdc5c1ba2 Remove all unwraps. diff --git a/src/main.rs b/src/main.rs --- a/src/main.rs +++ b/src/main.rs @@ -125,38 +125,38 @@ fn main() -> Result<(), Box> let output_filename = &args[4]; let vxseek = { - let mut vxseek = File::open(vxseek_filename).unwrap(); + let mut vxseek = File::open(vxseek_filename)?; let mut contents = String::new(); - vxseek.read_to_string(&mut contents).unwrap(); - parse_vxseek(&contents).unwrap() + vxseek.read_to_string(&mut contents)?; + parse_vxseek(&contents)? }; { - let vxvideo = File::open(vxvideo_filename).unwrap(); + let vxvideo = File::open(vxvideo_filename)?; let mut vxvideo = BufReader::new(vxvideo); - let output = File::create(output_filename).unwrap(); + let output = File::create(output_filename)?; let mut output = BufWriter::new(output); let mut name: Option = None; for VxSeekLine { timestamp, video_name, codec, resolution, unknown, length } in vxseek { if let Some(ref name) = &name { if &video_name != name { - vxvideo.seek(SeekFrom::Current(length as i64)).unwrap(); + vxvideo.seek(SeekFrom::Current(length as i64))?; continue; } } else { if resolution != wanted_resolution { println!("Skipping {} due to resolution {}", video_name, resolution); - vxvideo.seek(SeekFrom::Current(length as i64)).unwrap(); + vxvideo.seek(SeekFrom::Current(length as i64))?; continue; } name = Some(video_name); } let mut buf = Vec::with_capacity(length as usize); unsafe { buf.set_len(length as usize) }; - vxvideo.read_exact(&mut buf).unwrap(); - output.write_all(&buf).unwrap(); - output.flush().unwrap(); + vxvideo.read_exact(&mut buf)?; + output.write_all(&buf)?; + output.flush()?; } } Ok(())