summaryrefslogtreecommitdiff
path: root/ex6_4/src/main.rs
blob: da7dfe1cfa52b77065c44d45ac7660fa21d721b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#[derive(Debug)]
struct S {
    pub a: u32,
    pub b: u8,
}

struct T {
    pub v: Vec<S>
}

impl Iterator for T {
    type Item = S;

    fn next(&mut self) -> Option<Self::Item> {
        if self.v.is_empty() {
            None
        } else {
            Some(self.v.remove(0))
        }
    }
}

fn main() {
    println!("Hello, world!");
}

#[cfg(test)]
mod tests {
    use crate::*;

    #[test]
    fn t0() {
        let t = T{
            v: vec![
                S{a:1, b:2},
                S{a:3, b:4},
            ]};
        for i in t {
            println!("{:?}", i);
        }
        assert_eq!(0,0);
    }
}