use color::Color; struct Canvas { width: usize, height: usize, pixels: Vec>, } impl Canvas { fn new(width: usize, height: usize) -> Canvas { Canvas { width, height, pixels : vec![vec![Color::new(0.0, 0.0, 0.0); width]; height], } } } #[cfg(test)] mod tests { use super::*; #[test] fn create_canvas() { let c = Canvas::new(10, 20); assert_eq!(10, c.width); assert_eq!(20, c.height); let black = Color::new(0.0, 0.0, 0.0); for row in c.pixels { for pixel in row { assert_eq!(black, pixel); } } } }