use std::intrinsics::TypeId;
use GenericEvent;
use ptr::Ptr;
pub trait ResizeEvent {
fn from_width_height(w: u32, h: u32) -> Option<Self>;
fn resize<U>(&self, f: |u32, u32| -> U) -> Option<U>;
}
impl<T: GenericEvent> ResizeEvent for T {
#[inline(always)]
fn from_width_height(w: u32, h: u32) -> Option<T> {
let id = TypeId::of::<Box<ResizeEvent>>();
Ptr::with_ref::<(u32, u32), Option<T>>(&(w, h), |ptr| {
GenericEvent::from_event(id, ptr)
})
}
#[inline(always)]
fn resize<U>(&self, f: |u32, u32| -> U) -> Option<U> {
let id = TypeId::of::<Box<ResizeEvent>>();
self.with_event(id, |ptr| {
let &(w, h) = ptr.expect::<(u32, u32)>();
f(w, h)
})
}
}