Add dyn to trait objects

This commit is contained in:
Alexandre Bury 2019-06-18 11:35:42 -07:00
parent 5faf8d6c48
commit 269f2ab521
5 changed files with 5 additions and 5 deletions

View File

@ -47,7 +47,7 @@ pub struct Cursive {
cb_sink: Sender<Box<dyn CbFunc>>,
// User-provided data.
user_data: Box<Any>,
user_data: Box<dyn Any>,
fps: Option<NonZeroU32>,
boring_frame_count: u32,

View File

@ -27,7 +27,7 @@ pub struct Callback(Rc<Box<dyn Fn(&mut Cursive)>>);
// TODO: remove the Box when Box<T: Sized> -> Rc<T> is possible
/// A boxed callback that can be run on `&mut Any`.
pub type AnyCb<'a> = Box<FnMut(&mut dyn Any) + 'a>;
pub type AnyCb<'a> = Box<dyn FnMut(&mut dyn Any) + 'a>;
/// A trigger that only selects some types of events.
pub struct EventTrigger(Box<dyn Fn(&Event) -> bool>);

View File

@ -126,7 +126,7 @@ impl<T: ViewWrapper> View for T {
fn call_on_any<'a>(
&mut self, selector: &Selector<'_>,
callback: Box<FnMut(&mut dyn Any) + 'a>,
callback: Box<dyn FnMut(&mut dyn Any) + 'a>,
) {
self.wrap_call_on_any(selector, callback)
}

View File

@ -92,7 +92,7 @@ impl<V: View> ViewWrapper for HideableView<V> {
fn wrap_call_on_any<'a>(
&mut self, selector: &Selector<'_>,
callback: Box<FnMut(&mut dyn Any) + 'a>,
callback: Box<dyn FnMut(&mut dyn Any) + 'a>,
) {
// We always run callbacks, even when invisible.
self.view.call_on_any(selector, callback)

View File

@ -42,7 +42,7 @@ impl<V: View> IdView<V> {
}
// Shortcut for a boxed callback (for the wrap_call_on_any method).
type BoxedCallback<'a> = Box<for<'b> FnMut(&'b mut dyn Any) + 'a>;
type BoxedCallback<'a> = Box<dyn for<'b> FnMut(&'b mut dyn Any) + 'a>;
impl<T: View + 'static> ViewWrapper for IdView<T> {
type V = T;