Skip to content

Commit

Permalink
Replace usages of legacy numeric constants. (#103)
Browse files Browse the repository at this point in the history
The associated constants on the types are preferred as the legacy
items may be deprecated in the future.

See https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
for more details.
  • Loading branch information
waywardmonkeys authored May 14, 2024
1 parent 0f5d772 commit 21cd5f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions rasterizer/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ impl core::ops::Sub for Point {
/// # use ab_glyph_rasterizer::*;
/// let p1 = point(1.0, 2.0) - point(2.0, 1.5);
///
/// assert!((p1.x - -1.0).abs() <= core::f32::EPSILON);
/// assert!((p1.y - 0.5).abs() <= core::f32::EPSILON);
/// assert!((p1.x - -1.0).abs() <= f32::EPSILON);
/// assert!((p1.y - 0.5).abs() <= f32::EPSILON);
/// ```
#[inline]
fn sub(self, rhs: Point) -> Point {
Expand All @@ -71,8 +71,8 @@ impl core::ops::Add for Point {
/// # use ab_glyph_rasterizer::*;
/// let p1 = point(1.0, 2.0) + point(2.0, 1.5);
///
/// assert!((p1.x - 3.0).abs() <= core::f32::EPSILON);
/// assert!((p1.y - 3.5).abs() <= core::f32::EPSILON);
/// assert!((p1.x - 3.0).abs() <= f32::EPSILON);
/// assert!((p1.y - 3.5).abs() <= f32::EPSILON);
/// ```
#[inline]
fn add(self, rhs: Point) -> Point {
Expand All @@ -86,8 +86,8 @@ impl core::ops::AddAssign for Point {
/// let mut p1 = point(1.0, 2.0);
/// p1 += point(2.0, 1.5);
///
/// assert!((p1.x - 3.0).abs() <= core::f32::EPSILON);
/// assert!((p1.y - 3.5).abs() <= core::f32::EPSILON);
/// assert!((p1.x - 3.0).abs() <= f32::EPSILON);
/// assert!((p1.y - 3.5).abs() <= f32::EPSILON);
/// ```
#[inline]
fn add_assign(&mut self, other: Self) {
Expand All @@ -102,8 +102,8 @@ impl core::ops::SubAssign for Point {
/// let mut p1 = point(1.0, 2.0);
/// p1 -= point(2.0, 1.5);
///
/// assert!((p1.x - -1.0).abs() <= core::f32::EPSILON);
/// assert!((p1.y - 0.5).abs() <= core::f32::EPSILON);
/// assert!((p1.x - -1.0).abs() <= f32::EPSILON);
/// assert!((p1.y - 0.5).abs() <= f32::EPSILON);
/// ```
#[inline]
fn sub_assign(&mut self, other: Self) {
Expand Down Expand Up @@ -143,6 +143,6 @@ mod test {
#[test]
fn distance_to() {
let distance = point(0.0, 0.0).distance_to(point(3.0, 4.0));
assert!((distance - 5.0).abs() <= core::f32::EPSILON);
assert!((distance - 5.0).abs() <= f32::EPSILON);
}
}
2 changes: 1 addition & 1 deletion rasterizer/src/raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Rasterizer {

#[inline(always)] // must inline for simd versions
fn draw_line_scalar(&mut self, p0: Point, p1: Point) {
if (p0.y - p1.y).abs() <= core::f32::EPSILON {
if (p0.y - p1.y).abs() <= f32::EPSILON {
return;
}
let (dir, p0, p1) = if p0.y < p1.y {
Expand Down

0 comments on commit 21cd5f4

Please sign in to comment.