Skip to content

Commit

Permalink
enable manual_range_contains lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bircni committed Oct 2, 2024
1 parent 1406e87 commit a818ce5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ manual_clamp = "warn"
manual_instant_elapsed = "warn"
manual_let_else = "warn"
manual_ok_or = "warn"
manual_range_contains = "warn"
manual_string_new = "warn"
map_err_ignore = "warn"
map_flatten = "warn"
Expand Down Expand Up @@ -261,6 +262,5 @@ should_panic_without_expect = "allow"
too_many_lines = "allow"
unwrap_used = "allow" # TODO(emilk): We really wanna warn on this one

manual_range_contains = "allow" # this one is just worse imho
self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602
significant_drop_tightening = "allow" # Too many false positives
2 changes: 1 addition & 1 deletion crates/ecolor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn fast_round(r: f32) -> u8 {
pub fn test_srgba_conversion() {
for b in 0..=255 {
let l = linear_f32_from_gamma_u8(b);
assert!(0.0 <= l && l <= 1.0);
assert!((0.0..=1.0).contains(&l));
assert_eq!(gamma_u8_from_linear_f32(l), b);
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/ecolor/src/rgba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ impl Rgba {

#[inline]
pub fn from_luminance_alpha(l: f32, a: f32) -> Self {
debug_assert!(0.0 <= l && l <= 1.0);
debug_assert!(0.0 <= a && a <= 1.0);
debug_assert!((0.0..=1.0).contains(&l));
debug_assert!((0.0..=1.0).contains(&a));
Self([l * a, l * a, l * a, a])
}

/// Transparent black
#[inline]
pub fn from_black_alpha(a: f32) -> Self {
debug_assert!(0.0 <= a && a <= 1.0);
debug_assert!((0.0..=1.0).contains(&a));
Self([0.0, 0.0, 0.0, a])
}

/// Transparent white
#[inline]
pub fn from_white_alpha(a: f32) -> Self {
debug_assert!(0.0 <= a && a <= 1.0, "a: {a}");
debug_assert!((0.0..=1.0).contains(&a), "a: {a}");
Self([a, a, a, a])
}

Expand Down

0 comments on commit a818ce5

Please sign in to comment.