Created
January 3, 2014 07:27
-
-
Save Skrylar/8234218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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