1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use crate::{Coordinate, CoordinateType}; /// A bounded 2D quadrilateral whose area is defined by minimum and maximum `Coordinates`. #[derive(PartialEq, Clone, Copy, Debug)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Rect<T> where T: CoordinateType, { pub min: Coordinate<T>, pub max: Coordinate<T>, } impl<T: CoordinateType> Rect<T> { pub fn width(self) -> T { self.max.x - self.min.x } pub fn height(self) -> T { self.max.y - self.min.y } }