I'm running rustc 1.40.0.
The code:
fn main() {
let a = (0..3).chain([3, 4, 5].iter());
}
Trying to compile it results in:
% rustc test1.rs
error[E0271]: type mismatch resolving `<std::slice::Iter<'_, {integer}> as std::iter::IntoIterator>::Item == {integer}`
--> test1.rs:2:20
|
2 | let a = (0..3).chain([3, 4, 5].iter());
| ^^^^^ expected reference, found integer
|
= note: expected type `&{integer}`
found type `{integer}`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0271`.
If one focues one the ^^^^^ expected reference, found integer line (as I did) one is faced with the following difficulties:
- It's the
chain identifier that's underlined/pointed towards here which is (to me) confusing
- If I follow the "expected reference, found integer" advice naively and without trying to get to the bottom of things I may think "ok, the problem is with the
chain call, it expects references but I give it integers, let's add references" and produce the following:
fn main() {
let a = (0..3).chain([&3, &4, &5].iter());
}
And the error gets even more confusing:
% rustc test2.rs
error[E0271]: type mismatch resolving `<std::slice::Iter<'_, &{integer}> as std::iter::IntoIterator>::Item == {integer}`
--> test2.rs:2:20
|
2 | let a = (0..3).chain([&3, &4, &5].iter());
| ^^^^^ expected reference, found integer
|
= note: expected type `&&{integer}`
found type `{integer}`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0271`.
That attempt to fix things was of course totally incorrect, but the error messages don't help here.
I'm running rustc 1.40.0.
The code:
Trying to compile it results in:
If one focues one the
^^^^^ expected reference, found integerline (as I did) one is faced with the following difficulties:chainidentifier that's underlined/pointed towards here which is (to me) confusingchaincall, it expects references but I give it integers, let's add references" and produce the following:And the error gets even more confusing:
That attempt to fix things was of course totally incorrect, but the error messages don't help here.