Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Hacksaar
rinx
Commits
a72d1fc0
Commit
a72d1fc0
authored
Feb 14, 2016
by
Ralf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep track of the door-locked state
parent
afb07f0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
src/brain/environment.rs
src/brain/environment.rs
+9
-2
No files found.
src/brain/environment.rs
View file @
a72d1fc0
...
...
@@ -17,6 +17,7 @@ pub enum EventsResult {
pub
struct
Environment
{
events
:
Receiver
<
Event
>
,
door_locked
:
bool
,
}
impl
Environment
{
...
...
@@ -31,6 +32,7 @@ impl Environment {
timeout_chan
.recv
()
=>
return
EventsResult
::
Timeout
,
events
.recv
()
->
ev
=>
{
match
ev
{
None
=>
return
EventsResult
::
ShuttingDown
,
Some
(
ev
)
=>
{
self
.record_state
(
&
ev
);
for
handler
in
handlers
.iter_mut
()
{
...
...
@@ -40,7 +42,6 @@ impl Environment {
}
}
}
None
=>
return
EventsResult
::
ShuttingDown
,
}
}
}
...
...
@@ -48,7 +49,13 @@ impl Environment {
unreachable!
()
}
fn
record_state
(
&
mut
self
,
ev
:
&
Event
)
{}
fn
record_state
(
&
mut
self
,
ev
:
&
Event
)
{
match
ev
{
&
Event
::
DoorLocked
(
b
)
=>
self
.door_locked
=
b
,
_
=>
{},
}
}
pub
fn
door_locked
(
&
self
)
->
bool
{
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment