Skip to content

Commit

Permalink
Merge #240
Browse files Browse the repository at this point in the history
240: Refactoring with Clippy r=frewsxcv a=urschrei



Co-authored-by: Stephan Hügel <[email protected]>
  • Loading branch information
bors[bot] and urschrei committed May 21, 2018
2 parents 3013133 + 6f8a845 commit 6284b6a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 38 deletions.
8 changes: 4 additions & 4 deletions geo-types/src/algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ where
(b.y(), a.y())
};
Bbox {
xmin: xmin,
xmax: xmax,
ymin: ymin,
ymax: ymax,
xmin,
xmax,
ymin,
ymax,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions geo-types/src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ where
/// ```
pub fn new(start: Point<T>, end: Point<T>) -> Line<T> {
Line {
start: start,
end: end,
start,
end
}
}
}
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 @@ -51,7 +51,7 @@ where
/// assert_eq!(p.y(), 2.345);
/// ```
pub fn new(x: T, y: T) -> Point<T> {
Point(Coordinate { x: x, y: y })
Point(Coordinate { x, y })
}

/// Returns the x/horizontal component of the point.
Expand Down
4 changes: 2 additions & 2 deletions geo-types/src/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ where
/// ```
pub fn new(exterior: LineString<T>, interiors: Vec<LineString<T>>) -> Polygon<T> {
Polygon {
exterior: exterior,
interiors: interiors,
exterior,
interiors
}
}
/// Wrap-around previous-vertex
Expand Down
8 changes: 4 additions & 4 deletions geo/src/algorithm/boundingbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ where
(b.y(), a.y())
};
Bbox {
xmin: xmin,
xmax: xmax,
ymin: ymin,
ymax: ymax,
xmin,
xmax,
ymin,
ymax
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions geo/src/algorithm/haversine_intermediate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ where
{
fn haversine_intermediate(&self, other: &Point<T>, f: T) -> Point<T> {
let params = get_params(&self, &other);
let point = get_point(&params, f);
point
get_point(&params, f)
}

fn haversine_intermediate_fill(&self, other: &Point<T>, max_dist: T, include_ends: bool) -> Vec<Point<T>> {
Expand All @@ -55,7 +54,7 @@ where

if total_distance <= max_dist {
if include_ends {
return vec![self.clone(), other.clone()];
return vec![*self, *other];
} else {
return vec![];
}
Expand All @@ -65,7 +64,7 @@ where
let interval = T::one() / number_of_points;

let mut current_step = interval;
let mut points = if include_ends { vec![self.clone()] } else { vec![] };
let mut points = if include_ends { vec![*self] } else { vec![] };

while current_step < T::one() {
let point = get_point(&params, current_step);
Expand Down
12 changes: 6 additions & 6 deletions geo/src/algorithm/map_coords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for LineString<T

impl<T: CoordinateType> MapCoordsInplace<T> for LineString<T> {
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T)) {
for p in self.0.iter_mut() {
for p in &mut self.0 {
p.map_coords_inplace(func);
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for Polygon<T> {
impl<T: CoordinateType> MapCoordsInplace<T> for Polygon<T> {
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T)) {
self.exterior.map_coords_inplace(func);
for p in self.interiors.iter_mut() {
for p in &mut self.interiors {
p.map_coords_inplace(func);
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for MultiPoint<T

impl<T: CoordinateType> MapCoordsInplace<T> for MultiPoint<T> {
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T)) {
for p in self.0.iter_mut() {
for p in &mut self.0 {
p.map_coords_inplace(func);
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for MultiLineStr

impl<T: CoordinateType> MapCoordsInplace<T> for MultiLineString<T> {
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T)) {
for p in self.0.iter_mut() {
for p in &mut self.0 {
p.map_coords_inplace(func);
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for MultiPolygon

impl<T: CoordinateType> MapCoordsInplace<T> for MultiPolygon<T> {
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T)) {
for p in self.0.iter_mut() {
for p in &mut self.0 {
p.map_coords_inplace(func);
}
}
Expand Down Expand Up @@ -380,7 +380,7 @@ impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for GeometryColl

impl<T: CoordinateType> MapCoordsInplace<T> for GeometryCollection<T> {
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T)) {
for p in self.0.iter_mut() {
for p in &mut self.0 {
p.map_coords_inplace(func);
}
}
Expand Down
24 changes: 9 additions & 15 deletions geo/src/algorithm/winding_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ pub trait Winding<T> where T: CoordinateType
///
/// The object isn't changed, and the points are returned either in order, or in reverse
/// order, so that the resultant order makes it appear clockwise
fn points_cw<'a>(&'a self) -> Points<'a, T>;
fn points_cw(&self) -> Points<T>;

/// Iterate over the points in a counter-clockwise order
///
/// The object isn't changed, and the points are returned either in order, or in reverse
/// order, so that the resultant order makes it appear counter-clockwise
fn points_ccw<'a>(&'a self) -> Points<'a, T>;
fn points_ccw(&self) -> Points<T>;

/// Change this objects's points so they are in clockwise winding order
fn make_cw_winding(&mut self);
Expand Down Expand Up @@ -137,7 +137,7 @@ impl<T> Winding<T> for LineString<T>
///
/// The Linestring isn't changed, and the points are returned either in order, or in reverse
/// order, so that the resultant order makes it appear clockwise
fn points_cw<'a>(&'a self) -> Points<'a, T> {
fn points_cw(&self) -> Points<T> {
match self.winding_order() {
Some(WindingOrder::CounterClockwise) => Points(EitherIter::B(self.0.iter().rev())),
_ => Points(EitherIter::A(self.0.iter())),
Expand All @@ -148,7 +148,7 @@ impl<T> Winding<T> for LineString<T>
///
/// The Linestring isn't changed, and the points are returned either in order, or in reverse
/// order, so that the resultant order makes it appear counter-clockwise
fn points_ccw<'a>(&'a self) -> Points<'a, T> {
fn points_ccw(&self) -> Points<T> {
match self.winding_order() {
Some(WindingOrder::Clockwise) => Points(EitherIter::B(self.0.iter().rev())),
_ => Points(EitherIter::A(self.0.iter())),
Expand All @@ -157,21 +157,15 @@ impl<T> Winding<T> for LineString<T>

/// Change this line's points so they are in clockwise winding order
fn make_cw_winding(&mut self) {
match self.winding_order() {
Some(WindingOrder::CounterClockwise) => {
self.0.reverse();
},
_ => {},
}
if let Some(WindingOrder::CounterClockwise) = self.winding_order() {
self.0.reverse();
}
}

/// Change this line's points so they are in counterclockwise winding order
fn make_ccw_winding(&mut self) {
match self.winding_order() {
Some(WindingOrder::Clockwise) => {
self.0.reverse();
},
_ => {}
if let Some(WindingOrder::Clockwise) = self.winding_order() {
self.0.reverse();
}
}
}
Expand Down

0 comments on commit 6284b6a

Please sign in to comment.