Skip to content

Instantly share code, notes, and snippets.

@Skrylar
Created January 3, 2014 07:27
Show Gist options
  • Save Skrylar/8234218 to your computer and use it in GitHub Desktop.
Save Skrylar/8234218 to your computer and use it in GitHub Desktop.
pub trait ApplicationDelegate {
fn application_did_quit(&mut self, _timestamp: u32) {}
}
pub trait MouseDelegate {
fn mouse_did_move(&mut self, _info: &MouseMotionEventInfo) {}
fn mouse_did_click(&mut self, _info: &MouseButtonEventInfo) {}
fn mouse_did_scroll(&mut self, _info: &MouseWheelEventInfo) {}
}
pub struct NullDelegate;
impl ApplicationDelegate for NullDelegate {}
impl MouseDelegate for NullDelegate {}
impl NullDelegate {
pub fn as_app(&mut self) -> &mut ApplicationDelegate {
// ERROR: Failed to find an implementation of trait ApplicationDelegate...
// Removing mut doesn't fix it either.
&mut self as &mut ApplicationDelegate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment