RlpStream clear
This commit is contained in:
parent
fac89f784b
commit
f42e8c0665
22
src/rlp.rs
22
src/rlp.rs
@ -631,6 +631,28 @@ impl RlpStream {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clear the output stream so far.
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// extern crate ethcore_util as util;
|
||||||
|
/// use util::rlp::*;
|
||||||
|
///
|
||||||
|
/// fn main () {
|
||||||
|
/// let mut stream = RlpStream::new_list(3);
|
||||||
|
/// stream.append(&"cat");
|
||||||
|
/// stream.clear();
|
||||||
|
/// stream.append(&"dog");
|
||||||
|
/// let out = stream.out();
|
||||||
|
/// assert_eq!(out, vec![0x83, b'd', b'o', b'g']);
|
||||||
|
/// }
|
||||||
|
pub fn clear(&mut self) {
|
||||||
|
// clear bytes
|
||||||
|
self.encoder.bytes.clear();
|
||||||
|
|
||||||
|
// clear lists
|
||||||
|
self.unfinished_lists.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if stream doesnt expect any more items.
|
/// Returns true if stream doesnt expect any more items.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
Loading…
Reference in New Issue
Block a user