use std::char; use std::default::Default; use std::ops::Add; signal_decl!{Canceled(Option)} pub struct Rect { pub top: T, pub left: T, pub height: T, pub width: T } impl Rect { pub fn bottom(&self) -> ::Output where T: Add+Copy { self.top + self.height } pub fn right(&self) -> ::Output where T: Add+Copy { self.left + self.width } } impl Default for Rect where T: Default { fn default() -> Rect { Rect { top: Default::default(), left: Default::default(), height: Default::default(), width: Default::default(), } } } pub fn u4_to_hex(b: u8) -> char { char::from_digit(b as u32, 16).unwrap() } pub fn u8_to_hex(b: u8) -> (char, char) { (u4_to_hex((b >> 4) & 0xF), u4_to_hex(b & 0xF)) }