Quick actions

cmd+k|ctrl+k

Navigation

Languages

Iter

Snippet info

Language

Rust

Visibility

public

Author

ilicivan

Created

2018-02-09T03:08:08Z

Updated

2018-02-09T04:41:49Z

#[derive(Debug)]
struct Pixel {
    r: u8,
    g: u8,
    b: u8,
}

struct IntoIter(Pixel);

impl Pixel {
    pub fn into_iter(self) -> IntoIter {
        IntoIter(self)
    }
}

impl Iterator for IntoIter {
    type Item = u8;
    fn next(&mut self) -> Option<Self::Item> {
        // todo
        Some(self.0.r)
    }
}


fn main() {
    let p = Pixel {r:55, g:66, b:77};
    println!("{:?}", p)
}
INFO