#[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)
}
fn use_again(_names: Vec<&str>) {
}
fn main() {
let names = vec!["ßane", "Jill", "Jack", "John"];
let total = names.iter()
.map(|name: &&str| name.len())
.fold(0, |acc, len| acc + len );
assert_eq!(total, 17);
use_again(names);
let input = [1, 2, 3_u8];
let it = input.iter()
//.inspect(|&x| println!("Pre map:\t{}", x))
.map(|&x| x * 10)
//.inspect(|&x| println!("First map:\t{}", x))
//.map(|x| x + 5)
//.inspect(|&x| println!("Second map:\t{}", x));
.collect::<Vec<u8>>();
println!("{:?}", it)
}