4
我试图测试一些需要读取器的代码。我有一个功能:获取字节数组的读取器
fn next_byte<R: Read>(reader: &mut R) -> ...
我怎样才能测试它的一些字节数组?该文件说,有一个impl<'a> Read for &'a [u8]
,这将意味着这应该工作:
next_byte(&mut ([0x00u8, 0x00][..]))
但不同意编译:
the trait `std::io::Read` is not implemented for the type `[u8]`
为什么?我明确表示&mut
。
使用防锈1.2.0