Skip to content

Commit

Permalink
Minor Tidy: Removed multipoint.rs num_coords(). Fixed doctest code an…
Browse files Browse the repository at this point in the history
…d comments.
  • Loading branch information
martinfrances107 committed Dec 30, 2020
1 parent bfb2746 commit d347afd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
6 changes: 3 additions & 3 deletions geo-types/src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ where
/// let a = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1., y: 1. });
/// let b = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1.001, y: 1. });
///
/// approx::assert_relative_eq!(a, b, max_relative=0.1)
/// approx::assert_relative_eq!(a, b, max_relative=0.1);
/// ```
#[inline]
fn relative_eq(
Expand All @@ -211,7 +211,7 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordinateType> AbsDiffEq for Line<T> {
T::default_epsilon()
}

/// Equality assertion within a relative limit.
/// Equality assertion with a absolute limit.
///
/// # Examples
///
Expand All @@ -221,7 +221,7 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordinateType> AbsDiffEq for Line<T> {
/// let a = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1., y: 1. });
/// let b = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1.001, y: 1. });
///
/// approx::assert_relative_eq!(a, b, epsilon=0.1)
/// approx::assert_abs_diff_eq!(a, b, epsilon=0.1);
/// ```
#[inline]
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/line_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordinateType> AbsDiffEq for LineString<T> {
T::default_epsilon()
}

/// Equality assertion within a relative limit.
/// Equality assertion with a absolute limit.
///
/// # Examples
///
Expand Down
25 changes: 4 additions & 21 deletions geo-types/src/multi_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,6 @@ impl<T: CoordinateType> MultiPoint<T> {
}
}

impl<T: CoordinateType> MultiPoint<T> {
/// Return the number of coordinates in the `MultiPoint`.
///
/// # Examples
///
/// ```
/// use geo_types::MultiPoint;
///
/// let mut coords = vec![(0., 0.), (5., 0.), (7., 9.)];
/// let multi_point: MultiPoint<f32> = coords.into_iter().collect();
/// assert_eq!(3, multi_point.num_coords());
/// ```
pub fn num_coords(&self) -> usize {
self.0.len()
}
}

#[cfg(feature = "relative_eq")]
impl<T> RelativeEq for MultiPoint<T>
where
Expand Down Expand Up @@ -143,7 +126,7 @@ where
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool {
if self.num_coords() != other.num_coords() {
if self.0.len() != other.0.len() {
return false;
}

Expand All @@ -165,7 +148,7 @@ where
T::default_epsilon()
}

/// Equality assertion within a absolute limit.
/// Equality assertion with a absolute limit.
///
/// # Examples
///
Expand All @@ -176,11 +159,11 @@ where
/// let a = MultiPoint(vec![point![x: 0., y: 0.], point![x: 10., y: 10.]]);
/// let b = MultiPoint(vec![point![x: 0., y: 0.], point![x: 10.001, y: 10.]]);
///
/// approx::assert_relative_eq!(a, b, epsilon=0.1)
/// approx::abs_diff_eq!(a, b, epsilon=0.1);
/// ```
#[inline]
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
if self.num_coords() != other.num_coords() {
if self.0.len() != other.0.len() {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions geo-types/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,11 @@ where
T::default_epsilon()
}

/// Equality assertion within a absolute limit.
/// Equality assertion with a absolute limit.
///
/// # Examples
///
/// ```relative_eq
/// ```
/// use geo_types::Point;
///
/// let a = Point::new(2.0, 3.0);
Expand Down

0 comments on commit d347afd

Please sign in to comment.