pub fn write_iterator<T, I, B>(iterator: I, w: &mut B) -> Result<()>
Expand description
Write an Iterator
of EpeeValue
s to w
with write_varint
.
This function:
- Writes the length of the
iterator
, intow
usingwrite_varint
EpeeValue::write
s eachT
of the iterator intow
It is used as the internal EpeeValue::write
implementation of containers such as EpeeValue::<Vec<T>>::write
.
§Errors
This will error if:
write_varint
failsEpeeValue::<T>::write
fails
§Example
let t: u64 = 3;
let vec: Vec<u64> = vec![t, t];
let mut w = vec![];
let iter: std::vec::IntoIter<u64> = vec.into_iter();
cuprate_epee_encoding::write_iterator(iter, &mut w).unwrap();
assert_eq!(w.len(), 17);
assert_eq!(w[1..9], [3, 0, 0, 0, 0, 0, 0, 0]);
assert_eq!(w[9..], [3, 0, 0, 0, 0, 0, 0, 0]);