#[derive(Debug)]
pub struct Size {
pub width: usize,
pub height: usize
}
impl Size {
pub fn is_empty(&self) -> bool {
if self.width <= 0 || self.height <= 0 { true } else { false }
}
}
impl PartialEq for Size {
fn eq(&self, other: &Self) -> bool {
self.width == other.width && self.height == other.height
}
}
#[cfg(test)]
mod tests {
use crate::core::Size;
#[test]
fn test_empty() {
assert_eq!(Size {
width: 0,
height: 0
}.is_empty(), true);
}
#[test]
fn test_equality() {
assert_eq!(Size {
width: 10,
height: 20
}, Size {
width: 10,
height: 20
});
assert_ne!(Size {
width: 10,
height: 20
}, Size {
width: 11,
height: 20
});
}
}