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
#[cfg(test)]
mod tests {

    use super::*;
    #[test]
    fn it_works() {
        let mut fill_array = FillArray::new(3);
        assert_eq!(fill_array.next(), Some(1));
        assert_eq!(fill_array.next(), Some(2));
        assert_eq!(fill_array.next(), Some(3));
        assert_eq!(fill_array.next(), None);
    }
}

pub struct FillArray{
    count:u32,
    value:u32,
}

impl FillArray {
    pub fn new (count:u32) -> FillArray{
        FillArray{count:count, value:0}
    }
}

impl Iterator for FillArray{
    type Item = u32;

    fn next(&mut self) -> Option<Self::Item> {
        if self.value < self.count {
            self.value += 1;
            Some(self.value)
        } else {
            None
        }
    }
}