1
Fork 0
rust/src/test/ui/iterators/invalid-iterator-chain.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
871 B
Rust
Raw Normal View History

fn main() {
let scores = vec![(0, 0)]
.iter()
.map(|(a, b)| {
a + b;
});
println!("{}", scores.sum::<i32>()); //~ ERROR E0277
println!(
"{}",
vec![0, 1] //~ ERROR E0277
.iter()
2022-12-06 10:32:49 -08:00
.map(|x| x * 2)
.map(|x| x as f64)
.map(|x| x as i64)
.filter(|x| *x > 0)
.map(|x| { x + 1 })
.map(|x| { x; })
.sum::<i32>(),
);
println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); //~ ERROR E0277
println!("{}", vec![(), ()].iter().sum::<i32>()); //~ ERROR E0277
let a = vec![0];
let b = a.into_iter();
let c = b.map(|x| x + 1);
let d = c.filter(|x| *x > 10 );
let e = d.map(|x| {
x + 1;
});
let f = e.filter(|_| false);
let g: Vec<i32> = f.collect(); //~ ERROR E0277
}