There's a lot to digest in this snippet …
match event {
Event::KeyDown {
keycode: Some(Keycode::Escape),
..
} => break 'game,
_ => continue 'game,
}
With barely any prior introduction to the features shown it ends up hitting newcomers to Rust in the face like a wrecking ball.
It got them all:
enum with associated values.
- multi-level destructuring
Some(…) (which hides an Option::Some by eliding the Option::)
..
'game (I can count the number of times I've seen a label like this be used in the wild on one hand)
break vs. continue
_
=>
To make things worse: with the exception of "break vs. continue" none of these things can easily be searched for either.
The continue 'game should probably also be just continue, as else one could end up dropping events, that should be handled.
--
Over all it might make sense to add links to corresponding references in Rust by Example when introducing new concepts and syntax.
There's a lot to digest in this snippet …
With barely any prior introduction to the features shown it ends up hitting newcomers to Rust in the face like a wrecking ball.
It got them all:
enumwith associated values.Some(…)(which hides anOption::Someby eliding theOption::)..'game(I can count the number of times I've seen a label like this be used in the wild on one hand)breakvs.continue_=>To make things worse: with the exception of "
breakvs.continue" none of these things can easily be searched for either.The
continue 'gameshould probably also be justcontinue, as else one could end up dropping events, that should be handled.--
Over all it might make sense to add links to corresponding references in Rust by Example when introducing new concepts and syntax.