From e4479a449194167cb256ed46c7d310b05568dcb9 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sat, 24 Feb 2024 21:29:20 +0100 Subject: [PATCH] Fix clippy warnings Signed-off-by: Sjoerd Simons --- bmap-parser/src/discarder.rs | 2 +- bmap-parser/tests/copy.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bmap-parser/src/discarder.rs b/bmap-parser/src/discarder.rs index 93d8c6c..b57f5d8 100644 --- a/bmap-parser/src/discarder.rs +++ b/bmap-parser/src/discarder.rs @@ -95,7 +95,7 @@ mod test { .iter() .fold(0, |pos, offset| { let mut byte: u8 = 1; - discarder.seek_forward((offset - pos) as u64).unwrap(); + discarder.seek_forward(offset - pos).unwrap(); assert_eq!(1, discarder.read(slice::from_mut(&mut byte)).unwrap()); assert_eq!(*offset, byte as u64); *offset + 1 diff --git a/bmap-parser/tests/copy.rs b/bmap-parser/tests/copy.rs index 910145e..28b3495 100644 --- a/bmap-parser/tests/copy.rs +++ b/bmap-parser/tests/copy.rs @@ -118,14 +118,16 @@ fn setup_data(basename: &str) -> (Bmap, impl Read + SeekForward) { let mut bmapfile = datadir.clone(); bmapfile.push(format!("{}.bmap", basename)); - let mut b = File::open(&bmapfile).expect(&format!("Failed to open bmap file:{:?}", bmapfile)); + let mut b = + File::open(&bmapfile).unwrap_or_else(|_| panic!("Failed to open bmap file:{:?}", bmapfile)); let mut xml = String::new(); b.read_to_string(&mut xml).unwrap(); let bmap = Bmap::from_xml(&xml).unwrap(); let mut datafile = datadir.clone(); datafile.push(format!("{}.gz", basename)); - let g = File::open(&datafile).expect(&format!("Failed to open data file:{:?}", datafile)); + let g = + File::open(&datafile).unwrap_or_else(|_| panic!("Failed to open data file:{:?}", datafile)); let gz = GzDecoder::new(g); let gz = Discarder::new(gz);