1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2025-09-04 23:11:47 -04:00

Merge branch 'main' into comment_cleanup

This commit is contained in:
liv 2023-06-12 12:39:02 +02:00 committed by GitHub
commit b44472b237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 161 additions and 90 deletions
exercises/enums

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");
}
}