Skip to content

clippy: use clamp in camera.rs #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2022
Merged

clippy: use clamp in camera.rs #470

merged 1 commit into from
Oct 11, 2022

Conversation

darnuria
Copy link
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