rust/tests/ui/iterators/into-iter-on-boxed-slices-2024.rs
2024-05-20 19:21:30 -04:00

21 lines
580 B
Rust

//@ check-pass
//@ edition:2024
//@ compile-flags: -Zunstable-options
use std::ops::Deref;
use std::rc::Rc;
use std::vec::IntoIter;
fn main() {
let boxed_slice = vec![0; 10].into_boxed_slice();
// In 2021, the method dispatches to `IntoIterator for [T; N]`.
let _: IntoIter<i32> = boxed_slice.clone().into_iter();
// And through other boxes.
let _: IntoIter<i32> = Box::new(boxed_slice.clone()).into_iter();
// You can always use the trait method explicitly as a boxed_slice.
let _: IntoIter<i32> = IntoIterator::into_iter(boxed_slice.clone());
}