use crate::*; /// Handle input pub trait Handle: Send + Sync { fn handle (&mut self, context: &mut T) -> Perhaps; } impl Handle for &mut H where H: Handle { fn handle (&mut self, context: &mut T) -> Perhaps { (*self).handle(context) } } impl Handle for Option where H: Handle { fn handle (&mut self, context: &mut T) -> Perhaps { if let Some(ref mut handle) = self { handle.handle(context) } else { Ok(None) } } } impl Handle for Mutex where H: Handle { fn handle (&mut self, context: &mut T) -> Perhaps { self.lock().unwrap().handle(context) } } impl Handle for Arc> where H: Handle { fn handle (&mut self, context: &mut T) -> Perhaps { self.lock().unwrap().handle(context) } } impl Handle for RwLock where H: Handle { fn handle (&mut self, context: &mut T) -> Perhaps { self.write().unwrap().handle(context) } } impl Handle for Arc> where H: Handle { fn handle (&mut self, context: &mut T) -> Perhaps { self.write().unwrap().handle(context) } }