From a742f7dbd8bda0bf23a6d5273e5dd2f83b9d4c9f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 27 Jan 2023 21:48:22 +0100 Subject: clippy --- matroska/src/write.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'matroska/src/write.rs') diff --git a/matroska/src/write.rs b/matroska/src/write.rs index 8c1e7bb..6f8aad4 100644 --- a/matroska/src/write.rs +++ b/matroska/src/write.rs @@ -82,7 +82,7 @@ impl EbmlWriter { let mut bytes = i.to_be_bytes(); let trunc = &mut bytes[(8 - len)..]; trunc[0] |= 1 << (8 - len); - self.write(&trunc) + self.write(trunc) } } @@ -103,7 +103,7 @@ pub trait WriteValue { impl WriteValue for i64 { fn write_to(&self, w: &mut Vec) -> Result<()> { - Ok(match 64 - self.leading_zeros() { + match 64 - self.leading_zeros() { x if x <= 8 => { w.push(0x81); w.extend_from_slice(&(*self as i8).to_be_bytes()); @@ -120,12 +120,13 @@ impl WriteValue for i64 { w.push(0x88); w.extend_from_slice(&self.to_be_bytes()); } - }) + }; + Ok(()) } } impl WriteValue for u64 { fn write_to(&self, w: &mut Vec) -> Result<()> { - Ok(match 64 - self.leading_zeros() { + match 64 - self.leading_zeros() { x if x <= 8 => { w.push(0x81); w.extend_from_slice(&(*self as u8).to_be_bytes()); @@ -142,7 +143,8 @@ impl WriteValue for u64 { w.push(0x88); w.extend_from_slice(&self.to_be_bytes()); } - }) + }; + Ok(()) } } impl WriteValue for f64 { @@ -155,7 +157,7 @@ impl WriteValue for f64 { impl WriteValue for Vec { fn write_to(&self, w: &mut Vec) -> Result<(), anyhow::Error> { write_vint(w, self.len() as u64)?; - w.extend_from_slice(&self); + w.extend_from_slice(self); Ok(()) } } @@ -181,7 +183,10 @@ impl WriteValue for Master { fn write_to(&self, w: &mut Vec) -> Result<()> { match self { Master::Start => EbmlSize::Unknown.write_to(w), - Master::End => Ok(w.clear()), + Master::End => { + w.clear(); + Ok(()) + } Master::Collected(c) => { let mut ib = vec![]; for c in c { @@ -203,6 +208,6 @@ pub fn write_vint(w: &mut Vec, i: u64) -> Result<()> { let mut bytes = i.to_be_bytes(); let trunc = &mut bytes[(8 - len)..]; trunc[0] |= 1 << (8 - len); - w.extend_from_slice(&trunc); + w.extend_from_slice(trunc); Ok(()) } -- cgit v1.2.3-70-g09d2