Skip to content

Commit

Permalink
test fix, clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Mar 19, 2022
1 parent 9735ee2 commit c1e99d2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
7 changes: 6 additions & 1 deletion geo-types/src/coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ impl<T: CoordNum, Z: ZCoord, M: Measure> Add for CoordTZM<T, Z, M> {
type Output = Self;

fn add(self, rhs: Self) -> Self {
Self::new(self.x + rhs.x, self.y + rhs.y, self.z + rhs.z, self.m + rhs.m)
Self::new(
self.x + rhs.x,
self.y + rhs.y,
self.z + rhs.z,
self.m + rhs.m,
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod test {
let failure = Point::try_from(rect_geometry).unwrap_err();
assert_eq!(
failure.to_string(),
"Expected a geo_types::point::PointTZM<f64, geo_types::NoValue, geo_types::NoValue>, but found a geo_types::rect::RectTZM<f64, geo_types::NoValue, geo_types::NoValue>"
"Expected a geo_types::point::PointTZM<f64, geo_types::novalue::NoValue, geo_types::novalue::NoValue>, but found a geo_types::rect::RectTZM<f64, geo_types::novalue::NoValue, geo_types::novalue::NoValue>"
);
}
}
10 changes: 5 additions & 5 deletions geo-types/src/line.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{CoordNum, CoordTZM, Coordinate, Measure, NoValue, Point, PointTZM, ZCoord};
use crate::{CoordNum, CoordTZM, Coordinate, Measure, NoValue, PointTZM, ZCoord};
#[cfg(any(feature = "approx", test))]
use approx::{AbsDiffEq, RelativeEq};

Expand Down Expand Up @@ -236,23 +236,23 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordNum> AbsDiffEq for Line<T> {
#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9"))]
macro_rules! impl_rstar_line {
($rstar:ident) => {
impl<T> ::$rstar::RTreeObject for Line<T>
impl<T> ::$rstar::RTreeObject for crate::Line<T>
where
T: ::num_traits::Float + ::$rstar::RTreeNum,
{
type Envelope = ::$rstar::AABB<Point<T>>;
type Envelope = ::$rstar::AABB<crate::Point<T>>;

fn envelope(&self) -> Self::Envelope {
let bounding_rect = crate::private_utils::line_bounding_rect(*self);
::$rstar::AABB::from_corners(bounding_rect.min().into(), bounding_rect.max().into())
}
}

impl<T> ::$rstar::PointDistance for Line<T>
impl<T> ::$rstar::PointDistance for crate::Line<T>
where
T: ::num_traits::Float + ::$rstar::RTreeNum,
{
fn distance_2(&self, point: &Point<T>) -> T {
fn distance_2(&self, point: &crate::Point<T>) -> T {
let d = crate::private_utils::point_line_euclidean_distance(*point, *self);
d.powi(2)
}
Expand Down
11 changes: 4 additions & 7 deletions geo-types/src/line_string.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(any(feature = "approx", test))]
use approx::{AbsDiffEq, RelativeEq};

use crate::{CoordNum, CoordTZM, LineTZM, Measure, NoValue, Point, PointTZM, TriangleTZM, ZCoord};
use std::iter::FromIterator;
use std::ops::{Index, IndexMut};
Expand Down Expand Up @@ -400,9 +397,9 @@ impl<T: CoordNum, Z: ZCoord, M: Measure> IndexMut<usize> for LineStringTZM<T, Z,
}

#[cfg(any(feature = "approx", test))]
impl<T> RelativeEq for LineString<T>
impl<T> approx::RelativeEq for LineString<T>
where
T: AbsDiffEq<Epsilon = T> + CoordNum + RelativeEq,
T: approx::AbsDiffEq<Epsilon = T> + CoordNum + approx::RelativeEq,
{
#[inline]
fn default_max_relative() -> Self::Epsilon {
Expand Down Expand Up @@ -447,7 +444,7 @@ where
}

#[cfg(any(feature = "approx", test))]
impl<T: AbsDiffEq<Epsilon = T> + CoordNum> AbsDiffEq for LineString<T> {
impl<T: approx::AbsDiffEq<Epsilon = T> + CoordNum> approx::AbsDiffEq for LineString<T> {
type Epsilon = T;

#[inline]
Expand Down Expand Up @@ -530,7 +527,7 @@ impl_rstar_line_string!(rstar_0_9);
mod test {
use super::*;
use crate::{coord, Line};
use approx::AbsDiffEq;
use approx::{AbsDiffEq, RelativeEq};

#[test]
fn test_exact_size() {
Expand Down
5 changes: 3 additions & 2 deletions geo-types/src/novalue.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::ops::{Add, Div, Mul, Neg, Sub, Rem};
use std::fmt::Debug;
#[cfg(any(feature = "approx", test))]
use approx::AbsDiffEq;
use num_traits::Zero;
use std::fmt::Debug;
use std::ops::{Add, Div, Mul, Neg, Rem, Sub};

#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ where
#[cfg(test)]
mod test {
use super::*;

#[cfg(any(feature = "approx", test))]
use approx::AbsDiffEq;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ criterion = "0.3"
geo-test-fixtures = { path = "../geo-test-fixtures" }
# jts-test-runner is an internal crate which exists only to be part of the geo test suite.
# As such it's kept unpublished. It's in a separate repo primarily because it's kind of large.
jts-test-runner = { git = "https://github.com/nyurik/jts-test-runner", branch = "bump" }
jts-test-runner = { git = "https://github.com/georust/jts-test-runner" }
pretty_env_logger = "0.4"
rand = "0.8.0"

Expand Down

0 comments on commit c1e99d2

Please sign in to comment.