From 14cb4a65e495bf1d2eb43fb198f09a8256903361 Mon Sep 17 00:00:00 2001 From: Paul Young <84700+paulyoung@users.noreply.github.com> Date: Sun, 9 Jun 2024 15:23:09 -0700 Subject: [PATCH] Verify that we can update other parts of the state --- .../update-state-in-serial-message-callback.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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"); }, _ => {},