【发布时间】:2018-06-24 12:53:28
【问题描述】:
我正在尝试使用 byteorder crate 提供的特征:
extern crate byteorder;
use byteorder::{LittleEndian, ReadBytesExt};
fn main() {
let mut myArray = [0u8; 4];
myArray = [00000000, 01010101, 00100100, 11011011];
let result = myArray.read_u32::<LittleEndian>();
println!("{}", result);
}
我收到一个错误:
error[E0599]: no method named `read_u32` found for type `[u8; 4]` in the current scope
--> src/main.rs:10:26
|
10 | let result = myArray.read_u32::<LittleEndian>();
| ^^^^^^^^
|
= note: the method `read_u32` exists but the following trait bounds were not satisfied:
`[u8; 4] : byteorder::ReadBytesExt`
`[u8] : byteorder::ReadBytesExt`
我已经通读了几遍关于特质的书籍章节,无法理解为什么这里不满足特质绑定。
【问题讨论】:
标签: rust