【发布时间】:2016-01-07 07:39:49
【问题描述】:
在 Rust 中,这是可行的:
fn main() {
let a = [0; 32];
println!("{:?}", a);
}
但这不是:
fn main() {
let a = [0; 33];
println!("{:?}", a);
}
编译错误:
error[E0277]: the trait bound `[{integer}; 33]: std::fmt::Debug` is not satisfied
--> src/main.rs:3:22
|
3 | println!("{:?}", a);
| ^ the trait `std::fmt::Debug` is not implemented for `[{integer}; 33]`
|
= note: `[{integer}; 33]` cannot be formatted using `:?`; if it is defined in your crate, add `#[derive(Debug)]` or manually implement it
= note: required by `std::fmt::Debug::fmt`
我假设std::fmt::Debug 函数以某种方式检测到长度为 32 个元素的类型,但随后放弃了它的检测。或者为什么它不起作用?
【问题讨论】: