Skip to content

Commit

Permalink
Format the let-else statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Jul 5, 2023
1 parent 5163b56 commit 337f4f9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/ws_guessing_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ impl GuessingGame {

fn parse_guess(input: &str) -> Option<u32> {
// Trim control codes (including null bytes) and/or whitespace
let Ok(number) = u32::from_str_radix(input.trim_matches(|c: char| {
c.is_ascii_control() || c.is_whitespace()
}), 10) else {
let Ok(number) = u32::from_str_radix(
input.trim_matches(|c: char| c.is_ascii_control() || c.is_whitespace()),
10,
) else {
warn!("Not a number: `{}` (length {})", input, input.len());
return None;
};
Expand Down Expand Up @@ -167,7 +168,10 @@ fn main() -> anyhow::Result<()> {
};

let Some(user_guess) = GuessingGame::parse_guess(user_string) else {
ws.send(FrameType::Text(false), "Please enter a number between 1 and 100".as_bytes())?;
ws.send(
FrameType::Text(false),
"Please enter a number between 1 and 100".as_bytes(),
)?;
return Ok(());
};

Expand Down

0 comments on commit 337f4f9

Please sign in to comment.