Merge branch 'v0.4.x'

This commit is contained in:
Carl Lerche
2018-05-25 14:15:00 -07:00
5 changed files with 104 additions and 0 deletions
+21
View File
@@ -823,3 +823,24 @@ fn bytes_mut_unsplit_two_split_offs() {
buf.unsplit(buf2);
assert_eq!(b"aaaabbbbccccdddd", &buf[..]);
}
#[test]
fn from_iter_no_size_hint() {
use std::iter;
let mut expect = vec![];
let actual: Bytes = iter::repeat(b'x')
.scan(100, |cnt, item| {
if *cnt >= 1 {
*cnt -= 1;
expect.push(item);
Some(item)
} else {
None
}
})
.collect();
assert_eq!(&actual[..], &expect[..]);
}