Open
Description
I tried this code:
fn one() {
let v = vec![1, 2, 3].into_boxed_slice();
for elem in &v {
println!("elem: {}", elem);
}
}
fn two() {
let v = vec![1, 2, 3].into_boxed_slice();
for elem in &*v {
println!("elem: {}", elem);
}
}
I expected to see this happen: I expected both functions one
and two
to compile.
Instead, this happened: function one
does not compile:
Compiling playground v0.0.1 (/playground)
error[E0277]: `&Box<[{integer}]>` is not an iterator
--> src/lib.rs:4:17
|
4 | for elem in &v {
| ^^ `&Box<[{integer}]>` is not an iterator
|
= help: the trait `Iterator` is not implemented for `&Box<[{integer}]>`
= note: required because of the requirements on the impl of `IntoIterator` for `&Box<[{integer}]>`
= note: required by `into_iter`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
Meta
rustc --version --verbose
:
Stable channel
Build using the Stable version: 1.51.0