|
|
@ -9,13 +9,13 @@ enum Message {
|
|
|
|
|
|
|
|
|
|
|
|
struct Point {
|
|
|
|
struct Point {
|
|
|
|
x: u8,
|
|
|
|
x: u8,
|
|
|
|
y: u8
|
|
|
|
y: u8,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
struct State {
|
|
|
|
color: (u8, u8, u8),
|
|
|
|
color: (u8, u8, u8),
|
|
|
|
position: Point,
|
|
|
|
position: Point,
|
|
|
|
quit: bool
|
|
|
|
quit: bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl State {
|
|
|
|
impl State {
|
|
|
@ -49,7 +49,7 @@ mod tests {
|
|
|
|
let mut state = State {
|
|
|
|
let mut state = State {
|
|
|
|
quit: false,
|
|
|
|
quit: false,
|
|
|
|
position: Point { x: 0, y: 0 },
|
|
|
|
position: Point { x: 0, y: 0 },
|
|
|
|
color: (0, 0, 0)
|
|
|
|
color: (0, 0, 0),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
state.process(Message::ChangeColor((255, 0, 255)));
|
|
|
|
state.process(Message::ChangeColor((255, 0, 255)));
|
|
|
|
state.process(Message::Echo(String::from("hello world")));
|
|
|
|
state.process(Message::Echo(String::from("hello world")));
|
|
|
@ -61,5 +61,4 @@ mod tests {
|
|
|
|
assert_eq!(state.position.y, 15);
|
|
|
|
assert_eq!(state.position.y, 15);
|
|
|
|
assert_eq!(state.quit, true);
|
|
|
|
assert_eq!(state.quit, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|