Skip to content
Snippets Groups Projects
Commit 2b0602e7 authored by brianwp's avatar brianwp Committed by Carl Lerche
Browse files

impl ExactSizeIterator for Iter<T: Buf> (#127)

parent 3f5890be
No related branches found
No related tags found
No related merge requests found
......@@ -112,3 +112,5 @@ impl<T: Buf> Iterator for Iter<T> {
(rem, Some(rem))
}
}
impl<T: Buf> ExactSizeIterator for Iter<T> { }
extern crate bytes;
use bytes::{Buf, IntoBuf, Bytes};
#[test]
fn iter_len() {
let buf = Bytes::from(&b"hello world"[..]).into_buf();
let iter = buf.iter();
assert_eq!(iter.size_hint(), (11, Some(11)));
assert_eq!(iter.len(), 11);
}
#[test]
fn empty_iter_len() {
let buf = Bytes::from(&b""[..]).into_buf();
let iter = buf.iter();
assert_eq!(iter.size_hint(), (0, Some(0)));
assert_eq!(iter.len(), 0);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment