Closed
Description
fn main() {
let _v = {
[0, 1].into_iter()
}.collect::<Vec<_>>();
}
This yields:
rustc 1.14.0 (e8a012324 2016-12-16)
error: borrowed value does not live long enough
--> <anon>:5:9
|
5 | [0, 1].into_iter()
| ^^^^^^ temporary value created here
6 | }.collect::<Vec<_>>();
| - temporary value only lives until here
7 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
This is very confusing conceptually, since into_iter() is supposed to consume the value it iterates over. Presumably this happens because IntoIterator is only implemented for &[T; N]
and &mut [T; N]
, and not [T; N]
.
Metadata
Metadata
Assignees
Labels
No labels