use std::{fmt, convert::{TryFrom, TryInto}};
use crate::NCurseswWinError;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Region {
pub top: u16,
pub bottom: u16
}
impl TryInto<ncursesw::Region> for Region {
type Error = NCurseswWinError;
fn try_into(self) -> Result<ncursesw::Region, Self::Error> {
Ok(ncursesw::Region { top: u16::try_into(self.top)?, bottom: u16::try_into(self.bottom)? })
}
}
impl TryFrom<ncursesw::Region> for Region {
type Error = NCurseswWinError;
fn try_from(region: ncursesw::Region) -> Result<Self, Self::Error> {
Ok(Self { top: u16::try_from(region.top)?, bottom: u16::try_from(region.bottom)? })
}
}
impl fmt::Display for Region {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "(top: {}, bottom: {})", self.top, self.bottom)
}
}