From 120fe26b6b8187b3da3341fc213eed80a05c57f2 Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Mon, 7 Aug 2017 01:11:43 -0400 Subject: [PATCH] Cleanup results more --- src/ebml.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ebml.rs b/src/ebml.rs index 25c6705..4a39625 100644 --- a/src/ebml.rs +++ b/src/ebml.rs @@ -131,7 +131,7 @@ const EIGHT_FLAG: u64 = 0x01 << (8*7); const EIGHT_MAX: u64 = EIGHT_FLAG - 2; /// Tries to write an EBML varint using minimal space -pub fn encode_varint(varint: Varint, output: &mut T) -> IoResult { +pub fn encode_varint(varint: Varint, output: &mut T) -> IoResult<()> { let (size, number) = match varint { Varint::Unknown => (1, 0xFF), Varint::Value(too_big) if too_big > EIGHT_MAX => { @@ -155,14 +155,14 @@ pub fn encode_varint(varint: Varint, output: &mut T) -> IoResult(number, size); - return output.write_all(&buffer.get_ref()[..size]).map(|()| size); + return output.write_all(&buffer.get_ref()[..size]); } const FOUR_FLAG: u64 = 0x10 << (8*3); const FOUR_MAX: u64 = FOUR_FLAG - 2; // tries to write a varint with a fixed 4-byte representation -pub fn encode_varint_4(varint: Varint, output: &mut T) -> IoResult { +pub fn encode_varint_4(varint: Varint, output: &mut T) -> IoResult<()> { let number = match varint { Varint::Unknown => FOUR_FLAG | (FOUR_FLAG - 1), Varint::Value(too_big) if too_big > FOUR_MAX => { @@ -174,7 +174,7 @@ pub fn encode_varint_4(varint: Varint, output: &mut T) -> IoResult(number as u32); - return output.write_all(&buffer.get_ref()[..]).map(|()| 4); + output.write_all(&buffer.get_ref()[..]) } pub fn encode_element IoResult, X>(tag: u64, output: &mut T, content: F) -> IoResult<()> { @@ -194,15 +194,14 @@ pub fn encode_element IoResult, X>(tag: u64 pub fn encode_tag_header(tag: u64, size: Varint, output: &mut T) -> IoResult<()> { encode_varint(Varint::Value(tag), output)?; - encode_varint(size, output)?; - Ok(()) + encode_varint(size, output) } /// Tries to write a simple EBML tag with a string value pub fn encode_string(tag: u64, string: &str, output: &mut T) -> IoResult<()> { encode_tag_header(tag, Varint::Value(string.len() as u64), output)?; - output.write_all(string.as_ref()).map(|()| string.len())?; - Ok(()) + output.write_all(string.as_ref()) +} } #[derive(Debug, PartialEq)]