I'm trying to test some code which takes a reader. I've got a function:
fn next_byte<R: Read>(reader: &mut R) -> ...
How can I test it on some array of bytes? The docs say that there's a impl<'a> Read for &'a [u8]
, which would imply this should work:
next_byte(&mut ([0x00u8, 0x00][..]))
But compiler disagrees:
the trait `std::io::Read` is not implemented for the type `[u8]`
Why? I explicitly said &mut
.
Using rust 1.2.0