File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,8 @@ struct State {
34
34
fn main ( ) {
35
35
simple_logger:: init ( ) . unwrap ( ) ;
36
36
let main_window = WindowDesc :: new ( ui_builder) . menu ( make_menu ( & State :: default ( ) ) ) ;
37
- let delegate = Box :: new ( MultiwinDelegate { } ) ;
38
37
AppLauncher :: with_window ( main_window)
39
- . delegate ( delegate )
38
+ . delegate ( Delegate )
40
39
. launch ( State :: default ( ) )
41
40
. expect ( "launch failed" ) ;
42
41
}
@@ -82,9 +81,9 @@ fn ui_builder() -> impl Widget<State> {
82
81
col
83
82
}
84
83
85
- struct MultiwinDelegate { }
84
+ struct Delegate ;
86
85
87
- impl AppDelegate < State > for MultiwinDelegate {
86
+ impl AppDelegate < State > for Delegate {
88
87
fn event (
89
88
& mut self ,
90
89
event : Event ,
Original file line number Diff line number Diff line change @@ -70,8 +70,8 @@ impl<T: Data + 'static> AppLauncher<T> {
70
70
/// Set the [`AppDelegate`].
71
71
///
72
72
/// [`AppDelegate`]: struct.AppDelegate.html
73
- pub fn delegate ( mut self , delegate : Box < dyn AppDelegate < T > > ) -> Self {
74
- self . delegate = Some ( delegate) ;
73
+ pub fn delegate ( mut self , delegate : impl AppDelegate < T > + ' static ) -> Self {
74
+ self . delegate = Some ( Box :: new ( delegate) ) ;
75
75
self
76
76
}
77
77
Original file line number Diff line number Diff line change @@ -68,5 +68,10 @@ pub trait AppDelegate<T: Data> {
68
68
data : & mut T ,
69
69
env : & Env ,
70
70
ctx : & mut DelegateCtx ,
71
- ) -> Option < Event > ;
71
+ ) -> Option < Event > {
72
+ let _ = data;
73
+ let _ = env;
74
+ let _ = ctx;
75
+ Some ( event)
76
+ }
72
77
}
You can’t perform that action at this time.
0 commit comments