Merge branch 'main' into comment_cleanup

This commit is contained in:
liv
2023-06-12 12:39:02 +02:00
committed by GitHub
8 changed files with 161 additions and 90 deletions

View File

@@ -20,6 +20,7 @@ struct State {
color: (u8, u8, u8),
position: Point,
quit: bool,
message: String
}
impl State {
@@ -31,9 +32,7 @@ impl State {
self.quit = true;
}
fn echo(&self, s: String) {
println!("{}", s);
}
fn echo(&mut self, s: String) { self.message = s }
fn move_position(&mut self, p: Point) {
self.position = p;
@@ -57,6 +56,7 @@ mod tests {
quit: false,
position: Point { x: 0, y: 0 },
color: (0, 0, 0),
message: "hello world".to_string(),
};
state.process(Message::ChangeColor(255, 0, 255));
state.process(Message::Echo(String::from("hello world")));
@@ -67,5 +67,6 @@ mod tests {
assert_eq!(state.position.x, 10);
assert_eq!(state.position.y, 15);
assert_eq!(state.quit, true);
assert_eq!(state.message, "hello world");
}
}