diff options
author | metamuffin <metamuffin@disroot.org> | 2023-01-27 21:48:22 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-01-27 21:48:22 +0100 |
commit | a742f7dbd8bda0bf23a6d5273e5dd2f83b9d4c9f (patch) | |
tree | 49ba83ef7aec7b2bf4ff61b41c621696c45c6e95 /matroska/src/write.rs | |
parent | 04e3ebfdda613be0e58290a49536116cc57ad147 (diff) | |
download | jellything-a742f7dbd8bda0bf23a6d5273e5dd2f83b9d4c9f.tar jellything-a742f7dbd8bda0bf23a6d5273e5dd2f83b9d4c9f.tar.bz2 jellything-a742f7dbd8bda0bf23a6d5273e5dd2f83b9d4c9f.tar.zst |
clippy
Diffstat (limited to 'matroska/src/write.rs')
-rw-r--r-- | matroska/src/write.rs | 21 |
1 files changed, 13 insertions, 8 deletions
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<u8>) -> 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<u8>) -> 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<u8> { fn write_to(&self, w: &mut Vec<u8>) -> 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<u8>) -> 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<u8>, 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(()) } |