From 559b53456f6d4cb92b3cfc3262af6490c378d69e Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 6 Apr 2024 02:45:54 +0100 Subject: [PATCH] use clamp --- examples/the-dungeon-puzzlers-lament/src/game/game_state.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/the-dungeon-puzzlers-lament/src/game/game_state.rs b/examples/the-dungeon-puzzlers-lament/src/game/game_state.rs index cf5f44e6..75774fca 100644 --- a/examples/the-dungeon-puzzlers-lament/src/game/game_state.rs +++ b/examples/the-dungeon-puzzlers-lament/src/game/game_state.rs @@ -390,8 +390,7 @@ impl CursorState { let mut new_x = current_x.saturating_add_signed(lr as isize).max(1); let new_y = current_y .saturating_add_signed(ud as isize) - .max(1) - .min(PLAY_AREA_HEIGHT - 2); + .clamp(1, PLAY_AREA_HEIGHT - 2); if new_x == PLAY_AREA_WIDTH - 1 { new_x = new_x.min(PLAY_AREA_WIDTH - 2);