-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-boxArea: Our favorite opsem complicationArea: Our favorite opsem complicationA-iteratorsArea: IteratorsArea: IteratorsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-boxArea: Our favorite opsem complicationArea: Our favorite opsem complicationA-iteratorsArea: IteratorsArea: IteratorsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.