X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fcommon.rs;h=52b732482f6ee4ea6b8013786de9783feefcb9f9;hb=b0566120fd4a404355b6e6e1d75b472bbe3f57fe;hp=283640e87667e53ada0a7ecf6bfb332b98016b5e;hpb=6ba7aef184300a81cb7fb9533e926f663c0f806f;p=kaka%2Frust-sdl-test.git diff --git a/src/common.rs b/src/common.rs index 283640e..52b7324 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,7 @@ use std::ops::{Add, AddAssign, Mul}; +pub type Nanoseconds = u64; + #[macro_export] macro_rules! point { ( $x:expr, $y:expr ) => { @@ -7,7 +9,7 @@ macro_rules! point { }; } -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct Point2D { pub x: T, pub y: T, @@ -37,6 +39,22 @@ impl AddAssign for Point2D { } } +impl From<(T, T)> for Point2D { + fn from(item: (T, T)) -> Self { + Point2D { + x: item.0, + y: item.1, + } + } +} + +#[macro_export] +macro_rules! rect { + ( $x:expr, $y:expr ) => { + Rect { x: $x, y: $y } + }; +} + #[derive(Default)] pub struct Rect { pub width: T,