use core::convert::From;
use core::default::Default;
use std::fmt::{Debug, Formatter};
pub struct Area {
width: usize,
height: usize,
}
#[cfg(not(tarpaulin_include))]
impl Debug for Area {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut text = self.width.to_string();
text.push('×');
text.push_str(&self.height.to_string());
f.debug_tuple("Area").field(&text).finish()
}
}
impl Area {
#[must_use]
pub const fn new(width: usize, height: usize) -> Self {
Self { width, height }
}
#[must_use]
pub const fn width(&self) -> usize {
self.width
}
#[must_use]
pub const fn height(&self) -> usize {
self.height
}
}
impl From<(u16, u16)> for Area {
fn from(size: (u16, u16)) -> Self {
Self {
width: size.0.try_into().expect("u16 to usize"),
height: size.1.try_into().expect("u16 to usize"),
}
}
}
impl Default for Area {
fn default() -> Self {
Self {
width: 80,
height: 25,
}
}
}