Skip to content

Commit

Permalink
Verify that we can update other parts of the state
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyoung committed Jun 9, 2024
1 parent 1cd28ac commit 14cb4a6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api/system/examples/update-state-in-serial-message-callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ use system::event::SystemEventExt as _;
use system::prelude::*;

struct State {
initialized: bool,
latest_message: Option<String>,
}

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 {
Expand All @@ -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");
},
_ => {},
Expand Down

0 comments on commit 14cb4a6

Please sign in to comment.