diff --git a/api/system/examples/update-state-in-serial-message-callback.rs b/api/system/examples/update-state-in-serial-message-callback.rs index 4709ba14..1c0ca300 100644 --- a/api/system/examples/update-state-in-serial-message-callback.rs +++ b/api/system/examples/update-state-in-serial-message-callback.rs @@ -15,11 +15,15 @@ use system::event::SystemEventExt as _; use system::prelude::*; struct State { + initialized: bool, latest_message: Option, } impl State { - fn new() -> Self { Self { latest_message: None } } + fn new() -> Self { + Self { initialized: false, + latest_message: None } + } /// System event handler fn event(&'static mut self, event: SystemEvent) -> EventLoopCtrl { @@ -29,6 +33,10 @@ impl State { self.latest_message = Some(msg); })); + // Verify that `set_serial_message_callback` doesn't prevent us from + // updating other parts of `State` + self.initialized = true; + println!("Game init complete"); }, _ => {},