rust/src/test/ui/iterators/into-iter-on-arrays-2021.rs

16 lines
388 B
Rust
Raw Normal View History

// check-pass
// edition:2021
// compile-flags: -Zunstable-options
use std::array::IntoIter;
fn main() {
let array = [0; 10];
// In 2021, the method dispatches to `IntoIterator for [T; N]`.
let _: IntoIter<i32, 10> = array.into_iter();
// And you can always use the trait method explicitly as an array.
let _: IntoIter<i32, 10> = IntoIterator::into_iter(array);
}