From 9d2aebbc713ab2a567af8554ada69e993aeac93b Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 23 Apr 2021 14:36:12 +0530 Subject: apply clippy lints --- src/decode.rs | 21 +++++++-------------- src/encode.rs | 2 +- src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/decode.rs b/src/decode.rs index 9c6a065..2202116 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -18,8 +18,8 @@ pub fn decode_image(obi_data: &mut Cursor>) -> OBIResult { .read_u32::() .map_err(|_| OBIError::Decode)?; let file_header = FileHeader { - version, file_size, + version, data_offset, }; @@ -59,8 +59,7 @@ pub fn decode_image(obi_data: &mut Cursor>) -> OBIResult { obi_data .read_to_end(&mut rest) .map_err(|_| OBIError::Decode)?; - let data_points = rest - .iter() + rest.iter() .map(|&b| { BitVec::::from_element(b) .into_iter() @@ -68,23 +67,18 @@ pub fn decode_image(obi_data: &mut Cursor>) -> OBIResult { .collect::>() }) .flatten() - .collect::>(); - - let data = data_points .into_iter() .zip(lengths) .map(|(d, l)| vec![d; l as usize]) .flatten() - .collect::>(); - data + .collect::>() } _ => { let mut rest = vec![]; obi_data .read_to_end(&mut rest) .map_err(|_| OBIError::Decode)?; - let data_points = rest - .iter() + rest.iter() .map(|&b| { BitVec::::from_element(b) .into_iter() @@ -92,13 +86,12 @@ pub fn decode_image(obi_data: &mut Cursor>) -> OBIResult { .collect::>() }) .flatten() - .collect::>(); - data_points + .collect::>() } }; - return Ok(Image { + Ok(Image { file_header, image_info_header, data, - }); + }) } diff --git a/src/encode.rs b/src/encode.rs index 30edc49..e52b69b 100644 --- a/src/encode.rs +++ b/src/encode.rs @@ -76,5 +76,5 @@ where _ => write_pixel_data(pixmap, &mut obi_data)?, }; - return Ok(obi_data); + Ok(obi_data) } diff --git a/src/lib.rs b/src/lib.rs index 2eb01a9..05070cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -137,7 +137,7 @@ impl Image { if x >= self.width() || y >= self.height() { Err(OBIError::Image) } else { - return Ok((y * self.width() + x) as usize); + Ok((y * self.width() + x) as usize) } } -- cgit v1.2.3