1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#[derive(Clone)] pub struct Image { pub aspect_ratio: f64, pub width: usize, pub height: usize, } impl Image { pub fn new(aspect_ratio: f64, width: usize) -> Image { Image { aspect_ratio, width, height: (width as f64 / aspect_ratio) as usize, } } }