]> git.proxmox.com Git - rustc.git/blob - src/test/ui/iterators/iter-cloned-type-inference.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / iterators / iter-cloned-type-inference.rs
1 // run-pass
2 #![allow(stable_features)]
3
4 // Test to see that the element type of .cloned() can be inferred
5 // properly. Previously this would fail to deduce the type of `sum`.
6
7 #![feature(iter_arith)]
8
9 fn square_sum(v: &[i64]) -> i64 {
10 let sum: i64 = v.iter().cloned().sum();
11 sum * sum
12 }
13
14 fn main() {
15 assert_eq!(36, square_sum(&[1,2,3]));
16 }