Skip to content

Commit

Permalink
remove explicit generics when redundant with default
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed May 13, 2022
1 parent d375658 commit c0a720a
Show file tree
Hide file tree
Showing 35 changed files with 165 additions and 165 deletions.
16 changes: 8 additions & 8 deletions geo-postgis/src/from_postgis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ pub trait FromPostgis<T> {
fn from_postgis(_: T) -> Self;
}

impl<'a, T> FromPostgis<&'a T> for Point<f64>
impl<'a, T> FromPostgis<&'a T> for Point
where
T: postgis::Point,
{
fn from_postgis(pt: &'a T) -> Self {
Point::new(pt.x(), pt.y())
}
}
impl<'a, T> FromPostgis<&'a T> for LineString<f64>
impl<'a, T> FromPostgis<&'a T> for LineString
where
T: postgis::LineString<'a>,
{
fn from_postgis(ls: &'a T) -> Self {
let ret: Vec<Point<f64>> = ls.points().map(Point::from_postgis).collect();
let ret: Vec<Point> = ls.points().map(Point::from_postgis).collect();
LineString::from(ret)
}
}
Expand All @@ -50,7 +50,7 @@ where
Some(Polygon::new(exterior, rings))
}
}
impl<'a, T> FromPostgis<&'a T> for MultiPoint<f64>
impl<'a, T> FromPostgis<&'a T> for MultiPoint
where
T: postgis::MultiPoint<'a>,
{
Expand All @@ -59,7 +59,7 @@ where
MultiPoint::new(ret)
}
}
impl<'a, T> FromPostgis<&'a T> for MultiLineString<f64>
impl<'a, T> FromPostgis<&'a T> for MultiLineString
where
T: postgis::MultiLineString<'a>,
{
Expand All @@ -68,7 +68,7 @@ where
MultiLineString::new(ret)
}
}
impl<'a, T> FromPostgis<&'a T> for MultiPolygon<f64>
impl<'a, T> FromPostgis<&'a T> for MultiPolygon
where
T: postgis::MultiPolygon<'a>,
{
Expand All @@ -79,7 +79,7 @@ where
MultiPolygon::new(ret)
}
}
impl<'a, T> FromPostgis<&'a GeometryCollectionT<T>> for GeometryCollection<f64>
impl<'a, T> FromPostgis<&'a GeometryCollectionT<T>> for GeometryCollection
where
T: postgis::Point + postgis::ewkb::EwkbRead,
{
Expand All @@ -94,7 +94,7 @@ where
GeometryCollection::new_from(geoms)
}
}
impl<'a, T> FromPostgis<&'a GeometryT<T>> for Option<Geometry<f64>>
impl<'a, T> FromPostgis<&'a GeometryT<T>> for Option<Geometry>
where
T: postgis::Point + postgis::ewkb::EwkbRead,
{
Expand Down
8 changes: 4 additions & 4 deletions geo-postgis/src/to_postgis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ pub trait ToPostgis<T> {
}
}

impl ToPostgis<ewkb::Point> for Coordinate<f64> {
impl ToPostgis<ewkb::Point> for Coordinate {
fn to_postgis_with_srid(&self, srid: Option<i32>) -> ewkb::Point {
ewkb::Point::new(self.x, self.y, srid)
}
}

impl ToPostgis<ewkb::Point> for Point<f64> {
impl ToPostgis<ewkb::Point> for Point {
fn to_postgis_with_srid(&self, srid: Option<i32>) -> ewkb::Point {
ewkb::Point::new(self.x(), self.y(), srid)
}
}
impl ToPostgis<ewkb::LineString> for Line<f64> {
impl ToPostgis<ewkb::LineString> for Line {
fn to_postgis_with_srid(&self, srid: Option<i32>) -> ewkb::LineString {
let points = vec![
self.start_point().to_postgis_with_srid(srid),
Expand Down Expand Up @@ -67,7 +67,7 @@ to_postgis_impl!(MultiPolygon, ewkb::MultiPolygon, polygons);
to_postgis_impl!(MultiLineString, ewkb::MultiLineString, lines);
to_postgis_impl!(MultiPoint, ewkb::MultiPoint, points);
to_postgis_impl!(LineString, ewkb::LineString, points);
impl ToPostgis<ewkb::Geometry> for Geometry<f64> {
impl ToPostgis<ewkb::Geometry> for Geometry {
fn to_postgis_with_srid(&self, srid: Option<i32>) -> ewkb::Geometry {
match *self {
Geometry::Point(ref p) => ewkb::GeometryT::Point(p.to_postgis_with_srid(srid)),
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ use num_traits::Zero;
/// use geo_types::Coordinate;
/// use num_traits::Zero;
///
/// let p: Coordinate<f64> = Zero::zero();
/// let p: Coordinate = Zero::zero();
///
/// assert_eq!(p.x, 0.);
/// assert_eq!(p.y, 0.);
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::convert::TryFrom;
/// use std::convert::TryFrom;
/// use geo_types::{Point, point, Geometry, GeometryCollection};
/// let p = point!(x: 1.0, y: 1.0);
/// let pe: Geometry<f64> = p.into();
/// let pe: Geometry = p.into();
/// let pn = Point::try_from(pe).unwrap();
/// ```
///
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 @@ -63,7 +63,7 @@ use std::ops::{Index, IndexMut};
/// ```
/// use geo_types::LineString;
///
/// let line_string: LineString<f64> = vec![[0., 0.], [10., 0.]].into();
/// let line_string: LineString = vec![[0., 0.], [10., 0.]].into();
/// ```
//
/// Or by `collect`ing from a [`Coordinate`] iterator
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 @@ -22,9 +22,9 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssi
///
/// ```
/// use geo_types::{coord, Point};
/// let p1: Point<f64> = (0., 1.).into();
/// let p1: Point = (0., 1.).into();
/// let c = coord! { x: 10., y: 20. };
/// let p2: Point<f64> = c.into();
/// let p2: Point = c.into();
/// ```
#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions geo/benches/geodesic_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use geo::prelude::*;

fn criterion_benchmark(c: &mut criterion::Criterion) {
c.bench_function("geodesic distance f64", |bencher| {
let a = geo::Point::<f64>::new(17.107558, 48.148636);
let b = geo::Point::<f64>::new(16.372477, 48.208810);
let a = geo::Point::new(17.107558, 48.148636);
let b = geo::Point::new(16.372477, 48.208810);

bencher.iter(|| {
criterion::black_box(
Expand Down
4 changes: 2 additions & 2 deletions geo/benches/intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use geo::intersects::Intersects;
use geo::MultiPolygon;

fn criterion_benchmark(c: &mut Criterion) {
let plot_polygons: MultiPolygon<f64> = geo_test_fixtures::nl_plots();
let zone_polygons: MultiPolygon<f64> = geo_test_fixtures::nl_zones();
let plot_polygons: MultiPolygon = geo_test_fixtures::nl_plots();
let zone_polygons: MultiPolygon = geo_test_fixtures::nl_zones();

c.bench_function("intersection", |bencher| {
bencher.iter(|| {
Expand Down
4 changes: 2 additions & 2 deletions geo/benches/vincenty_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fn criterion_benchmark(c: &mut criterion::Criterion) {
});

c.bench_function("vincenty distance f64", |bencher| {
let a = geo::Point::<f64>::new(17.107558, 48.148636);
let b = geo::Point::<f64>::new(16.372477, 48.208810);
let a = geo::Point::new(17.107558, 48.148636);
let b = geo::Point::new(16.372477, 48.208810);

bencher.iter(|| {
let _ = criterion::black_box(
Expand Down
8 changes: 4 additions & 4 deletions geo/examples/concavehull-usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use geo_types::MultiPoint;
use std::fs::File;
use std::io::Write;

fn generate_polygon_str(coords: &[Coordinate<f64>]) -> String {
fn generate_polygon_str(coords: &[Coordinate]) -> String {
let mut points_str = String::from("");
for coord in coords {
points_str.push_str(format!("{},{} ", coord.x, coord.y).as_ref());
Expand All @@ -16,7 +16,7 @@ fn generate_polygon_str(coords: &[Coordinate<f64>]) -> String {
);
}

fn generate_consecutive_circles(coords: &[Coordinate<f64>]) -> String {
fn generate_consecutive_circles(coords: &[Coordinate]) -> String {
let mut circles_str = String::from("");
for coord in coords {
circles_str.push_str(
Expand All @@ -34,7 +34,7 @@ fn produce_file_content(start_str: &str, mid_str: &str) -> String {
}

//Move the points such that they're clustered around the center of the image
fn move_points_in_viewbox(width: f64, height: f64, points: Vec<Point<f64>>) -> Vec<Point<f64>> {
fn move_points_in_viewbox(width: f64, height: f64, points: Vec<Point>) -> Vec<Point> {
let mut new_points = vec![];
for point in points {
new_points.push(Point::new(
Expand All @@ -45,7 +45,7 @@ fn move_points_in_viewbox(width: f64, height: f64, points: Vec<Point<f64>>) -> V
new_points
}

fn map_points_to_coords(points: Vec<Point<f64>>) -> Vec<Coordinate<f64>> {
fn map_points_to_coords(points: Vec<Point>) -> Vec<Coordinate> {
points.iter().map(|point| point.0).collect()
}

Expand Down
4 changes: 2 additions & 2 deletions geo/src/algorithm/bearing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub trait Bearing<T: CoordFloat> {
/// use geo::algorithm::bearing::Bearing;
/// use geo::Point;
///
/// let p_1 = Point::<f64>::new(9.177789688110352, 48.776781529534965);
/// let p_2 = Point::<f64>::new(9.274410083250379, 48.84033282787534);
/// let p_1 = Point::new(9.177789688110352, 48.776781529534965);
/// let p_2 = Point::new(9.274410083250379, 48.84033282787534);
/// let bearing = p_1.bearing(p_2);
/// assert_relative_eq!(bearing, 45., epsilon = 1.0e-6);
/// ```
Expand Down
11 changes: 6 additions & 5 deletions geo/src/algorithm/centroid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ where
/// use geo::algorithm::centroid::Centroid;
/// use geo::{MultiPoint, Point};
///
/// let empty: Vec<Point<f64>> = Vec::new();
/// let empty: Vec<Point> = Vec::new();
/// let empty_multi_points: MultiPoint<_> = empty.into();
/// assert_eq!(empty_multi_points.centroid(), None);
///
Expand Down Expand Up @@ -519,13 +519,13 @@ mod test {
// Tests: Centroid of MultiLineString
#[test]
fn empty_multilinestring_test() {
let mls: MultiLineString<f64> = MultiLineString::new(vec![]);
let mls: MultiLineString = MultiLineString::new(vec![]);
let centroid = mls.centroid();
assert!(centroid.is_none());
}
#[test]
fn multilinestring_with_empty_line_test() {
let mls: MultiLineString<f64> = MultiLineString::new(vec![line_string![]]);
let mls: MultiLineString = MultiLineString::new(vec![line_string![]]);
let centroid = mls.centroid();
assert!(centroid.is_none());
}
Expand All @@ -535,7 +535,7 @@ mod test {
x: 40.02f64,
y: 116.34,
};
let mls: MultiLineString<f64> = MultiLineString::new(vec![
let mls: MultiLineString = MultiLineString::new(vec![
line_string![coord],
line_string![coord],
line_string![coord],
Expand All @@ -552,7 +552,7 @@ mod test {
(x: 10., y: 1.),
(x: 11., y: 1.)
];
let mls: MultiLineString<f64> = MultiLineString::new(vec![linestring]);
let mls: MultiLineString = MultiLineString::new(vec![linestring]);
assert_relative_eq!(mls.centroid().unwrap(), point! { x: 6., y: 1. });
}
#[test]
Expand Down Expand Up @@ -752,6 +752,7 @@ mod test {
fn empty_multipolygon_polygon_test() {
assert!(MultiPolygon::<f64>::new(Vec::new()).centroid().is_none());
}

#[test]
fn multipolygon_one_polygon_test() {
let linestring =
Expand Down
2 changes: 1 addition & 1 deletion geo/src/algorithm/concave_hull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ mod test {
#[test]
fn concave_hull_norway_test() {
let norway = geo_test_fixtures::norway_main::<f64>();
let norway_concave_hull: LineString<f64> = geo_test_fixtures::norway_concave_hull::<f64>();
let norway_concave_hull: LineString = geo_test_fixtures::norway_concave_hull::<f64>();
let res = norway.concave_hull(2.0);
assert_eq!(res.exterior(), &norway_concave_hull);
}
Expand Down
12 changes: 6 additions & 6 deletions geo/src/algorithm/contains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,17 @@ mod test {
#[test]
// https://github.com/georust/geo/issues/473
fn triangle_contains_collinear_points() {
let origin: Coordinate<f64> = (0., 0.).into();
let origin: Coordinate = (0., 0.).into();
let tri = Triangle::new(origin, origin, origin);
let pt: Point<f64> = (0., 1.23456).into();
let pt: Point = (0., 1.23456).into();
assert!(!tri.contains(&pt));
let pt: Point<f64> = (0., 0.).into();
let pt: Point = (0., 0.).into();
assert!(!tri.contains(&pt));
let origin: Coordinate<f64> = (0., 0.).into();
let origin: Coordinate = (0., 0.).into();
let tri = Triangle::new((1., 1.).into(), origin, origin);
let pt: Point<f64> = (1., 1.).into();
let pt: Point = (1., 1.).into();
assert!(!tri.contains(&pt));
let pt: Point<f64> = (0.5, 0.5).into();
let pt: Point = (0.5, 0.5).into();
assert!(!tri.contains(&pt));
}
}
10 changes: 5 additions & 5 deletions geo/src/algorithm/coords_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,11 @@ mod test {
assert_eq!(expected_coords, actual_coords);
}

fn create_point() -> (Point<f64>, Vec<Coordinate<f64>>) {
fn create_point() -> (Point, Vec<Coordinate>) {
(point!(x: 1., y: 2.), vec![coord! { x: 1., y: 2. }])
}

fn create_triangle() -> (Triangle<f64>, Vec<Coordinate<f64>>) {
fn create_triangle() -> (Triangle, Vec<Coordinate>) {
(
Triangle::new(
coord! { x: 1., y: 2. },
Expand All @@ -785,7 +785,7 @@ mod test {
)
}

fn create_rect() -> (Rect<f64>, Vec<Coordinate<f64>>) {
fn create_rect() -> (Rect, Vec<Coordinate>) {
(
Rect::new(coord! { x: 1., y: 2. }, coord! { x: 3., y: 4. }),
vec![
Expand All @@ -797,7 +797,7 @@ mod test {
)
}

fn create_line_string() -> (LineString<f64>, Vec<Coordinate<f64>>) {
fn create_line_string() -> (LineString, Vec<Coordinate>) {
(
line_string![
(x: 1., y: 2.),
Expand All @@ -807,7 +807,7 @@ mod test {
)
}

fn create_polygon() -> (Polygon<f64>, Vec<Coordinate<f64>>) {
fn create_polygon() -> (Polygon<f64>, Vec<Coordinate>) {
(
polygon!(
exterior: [(x: 0., y: 0.), (x: 5., y: 10.), (x: 10., y: 0.), (x: 0., y: 0.)],
Expand Down
2 changes: 1 addition & 1 deletion geo/src/algorithm/dimensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait HasDimensions {
/// ]);
/// assert!(!line_string.is_empty());
///
/// let empty_line_string: LineString<f64> = LineString::new(vec![]);
/// let empty_line_string: LineString = LineString::new(vec![]);
/// assert!(empty_line_string.is_empty());
///
/// let point = Point::new(0.0, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion geo/src/algorithm/euclidean_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ mod test {
#[test]
fn distance1_test() {
assert_relative_eq!(
Point::<f64>::new(0., 0.).euclidean_distance(&Point::<f64>::new(1., 0.)),
Point::new(0., 0.).euclidean_distance(&Point::new(1., 0.)),
1.
);
}
Expand Down
4 changes: 2 additions & 2 deletions geo/src/algorithm/geodesic_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub trait GeodesicDistance<T, Rhs = Self> {
fn geodesic_distance(&self, rhs: &Rhs) -> T;
}

impl GeodesicDistance<f64> for Point<f64> {
fn geodesic_distance(&self, rhs: &Point<f64>) -> f64 {
impl GeodesicDistance<f64> for Point {
fn geodesic_distance(&self, rhs: &Point) -> f64 {
Geodesic::wgs84().inverse(self.y(), self.x(), rhs.y(), rhs.x())
}
}
Loading

0 comments on commit c0a720a

Please sign in to comment.