जंग में, यह काम करता है:प्रिंटल क्यों करता है! केवल 33 से कम लंबाई वाले सरणी के लिए काम करते हैं?
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 तत्वों की लंबाई, लेकिन फिर इसकी पहचान छोड़ देता है। या यह क्यों काम नहीं करता है?
[मैक्रो कार्यान्वयन के लिए बस एक लिंक] (https://github.com/rust-lang/rust/blob/b30d8969e86fa2c9dd3b8e2e28ddda2202331f0f/src/libcore/array.rs#L112) - मुझे लगता है, यह सहायक हो सकता है। – soon