Skip to content

clippy: use clamp in camera.rs#470

Merged
orhun merged 1 commit into
fishfolk:mainfrom
darnuria:clippy/clamp
Oct 11, 2022
Merged

clippy: use clamp in camera.rs#470
orhun merged 1 commit into
fishfolk:mainfrom
darnuria:clippy/clamp

Conversation

@darnuria

Copy link
Copy Markdown
Contributor

Rational:

warning: clamp-like pattern without using clamp function
  --> src/game/camera.rs:68:17
   |
68 |                 rect.x.max(min.x).min(max.x),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `rect.x.clamp(min.x, max.x)`
   |
   = note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
   = note: clamp returns NaN if the input is NaN
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
   = note: `#[warn(clippy::manual_clamp)]` on by default

warning: clamp-like pattern without using clamp function
  --> src/game/camera.rs:69:17
   |
69 |                 rect.y.max(min.y).min(max.y),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `rect.y.clamp(min.y, max.y)`
   |
   = note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
   = note: clamp returns NaN if the input is NaN
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp

Rationnal:
```
warning: clamp-like pattern without using clamp function
  --> src/game/camera.rs:68:17
   |
68 |                 rect.x.max(min.x).min(max.x),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `rect.x.clamp(min.x, max.x)`
   |
   = note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
   = note: clamp returns NaN if the input is NaN
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
   = note: `#[warn(clippy::manual_clamp)]` on by default

warning: clamp-like pattern without using clamp function
  --> src/game/camera.rs:69:17
   |
69 |                 rect.y.max(min.y).min(max.y),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `rect.y.clamp(min.y, max.y)`
   |
   = note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
   = note: clamp returns NaN if the input is NaN
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
```
@orhun orhun changed the title [clippy] Use clamp in camera.rs clippy: use clamp in camera.rs Oct 11, 2022
@orhun
orhun merged commit 2e79f68 into fishfolk:main Oct 11, 2022
@darnuria
darnuria deleted the clippy/clamp branch October 11, 2022 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants