1 //! This module provides a type that represents some size.
2 //! For example, in WinAPI we have `COORD` to represent screen/buffer size but this is a little inconvenient.
3 //! This module provides some trait implementations who will make parsing and working with `COORD` easier.
4 
5 use winapi::um::wincon::COORD;
6 
7 /// This is type represents the size of something in width and height.
8 #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
9 pub struct Size {
10     pub width: i16,
11     pub height: i16,
12 }
13 
14 impl Size {
15     /// Create a new size instance by passing in the width and height.
new(width: i16, height: i16) -> Size16     pub fn new(width: i16, height: i16) -> Size {
17         Size { width, height }
18     }
19 }
20 
21 impl From<COORD> for Size {
from(coord: COORD) -> Self22     fn from(coord: COORD) -> Self {
23         Size::new(coord.X, coord.Y)
24     }
25 }
26 
27 impl Into<(u16, u16)> for Size {
into(self) -> (u16, u16)28     fn into(self) -> (u16, u16) {
29         (self.width as u16, self.height as u16)
30     }
31 }
32