From 1c2c8c4eb5dba77d91c6029c2954e0bad67a253d Mon Sep 17 00:00:00 2001 From: debris Date: Wed, 25 Nov 2015 22:16:50 +0100 Subject: [PATCH] removed last_err field from RlpStream --- src/rlp.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/rlp.rs b/src/rlp.rs index 48dbccc55..bd5561635 100644 --- a/src/rlp.rs +++ b/src/rlp.rs @@ -193,8 +193,7 @@ impl <'a> Iterator for RlpIterator<'a> { pub struct RlpStream { len: usize, max_len: usize, - bytes: Vec, - last_err: Option + bytes: Vec } impl RlpStream { @@ -209,18 +208,12 @@ impl RlpStream { RlpStream { len: 0, max_len: max_len, - bytes: vec![], - last_err: None + bytes: vec![] } } /// apends value to the end of stream, chainable pub fn append<'a, E>(&'a mut self, object: &E) -> &'a mut RlpStream where E: Encodable { - // if there was an error, stop appending - if !self.last_err.is_none() { - return self - } - // encode given value and add it at the end of the stream self.bytes.extend(encode(object)); self.len += 1; @@ -241,10 +234,9 @@ impl RlpStream { /// streams out encoded bytes pub fn out(self) -> Result, EncoderError> { - match self.last_err { - None if self.is_finished() => Ok(self.bytes), - Some(e) => Err(e), - _ => Err(EncoderError::StreamIsUnfinished) + match self.is_finished() { + true => Ok(self.bytes), + false => Err(EncoderError::StreamIsUnfinished) } }