]> git.proxmox.com Git - rustc.git/blob - src/test/ui/specialization/issue-36804.rs
Update upstream source from tag 'upstream/1.40.0+dfsg1'
[rustc.git] / src / test / ui / specialization / issue-36804.rs
1 // check-pass
2 #![feature(specialization)]
3
4 pub struct Cloned<I>(I);
5
6 impl<'a, I, T: 'a> Iterator for Cloned<I>
7 where
8 I: Iterator<Item = &'a T>,
9 T: Clone,
10 {
11 type Item = T;
12
13 fn next(&mut self) -> Option<T> {
14 unimplemented!()
15 }
16
17 default fn count(self) -> usize where Self: Sized {
18 self.fold(0, |cnt, _| cnt + 1)
19 }
20 }
21
22 impl<'a, I, T: 'a> Iterator for Cloned<I>
23 where
24 I: Iterator<Item = &'a T>,
25 T: Copy,
26 {
27 fn count(self) -> usize {
28 unimplemented!()
29 }
30 }
31
32 fn main() {
33 let a = [1,2,3,4];
34 Cloned(a.iter()).count();
35 }