Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary trait bounds. #320

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions geo-types/src/coordinate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use num_traits::ToPrimitive;
use {CoordinateType, Point};

/// A lightweight struct used to store coordinates on the 2-dimensional
Expand Down Expand Up @@ -47,7 +46,7 @@ impl<T: CoordinateType> From<Point<T>> for Coordinate<T> {

impl<T> Coordinate<T>
where
T: CoordinateType + ToPrimitive,
T: CoordinateType,
{
/// Returns a tuple that contains the x/horizontal & y/vertical component of the coordinate.
///
Expand Down
10 changes: 5 additions & 5 deletions geo-types/src/point.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use num_traits::{Float, ToPrimitive};
use num_traits::Float;
use std::ops::Add;
use std::ops::Neg;
use std::ops::Sub;
Expand Down Expand Up @@ -36,7 +36,7 @@ impl<T: CoordinateType> From<(T, T)> for Point<T> {

impl<T> Point<T>
where
T: CoordinateType + ToPrimitive,
T: CoordinateType,
{
/// Creates a new point.
///
Expand Down Expand Up @@ -283,7 +283,7 @@ where

impl<T> Neg for Point<T>
where
T: CoordinateType + Neg<Output = T> + ToPrimitive,
T: CoordinateType + Neg<Output = T>,
{
type Output = Point<T>;

Expand All @@ -306,7 +306,7 @@ where

impl<T> Add for Point<T>
where
T: CoordinateType + ToPrimitive,
T: CoordinateType,
{
type Output = Point<T>;

Expand All @@ -329,7 +329,7 @@ where

impl<T> Sub for Point<T>
where
T: CoordinateType + ToPrimitive,
T: CoordinateType,
{
type Output = Point<T>;

Expand Down
14 changes: 7 additions & 7 deletions geo-types/src/private_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// hidden module is public so the geo crate can reuse these algorithms to
// prevent duplication. These functions are _not_ meant for public consumption.

use num_traits::{Float, ToPrimitive};
use num_traits::Float;
use {Coordinate, CoordinateType, Line, LineString, Point, Rect};

pub static COORD_PRECISION: f32 = 1e-1; // 0.1m
Expand Down Expand Up @@ -72,7 +72,7 @@ where

pub fn line_segment_distance<T>(point: Point<T>, start: Point<T>, end: Point<T>) -> T
where
T: Float + ToPrimitive,
T: Float,
{
if start == end {
return line_euclidean_length(Line::new(point, start));
Expand All @@ -93,14 +93,14 @@ where

pub fn line_euclidean_length<T>(line: Line<T>) -> T
where
T: Float + ToPrimitive,
T: Float,
{
line.dx().hypot(line.dy())
}

pub fn point_line_string_euclidean_distance<T>(p: Point<T>, l: &LineString<T>) -> T
where
T: Float + ToPrimitive,
T: Float,
{
// No need to continue if the point is on the LineString, or it's empty
if line_string_contains_point(l, p) || l.0.is_empty() {
Expand All @@ -113,21 +113,21 @@ where

pub fn point_line_euclidean_distance<T>(p: Point<T>, l: Line<T>) -> T
where
T: Float + ToPrimitive,
T: Float,
{
line_segment_distance(p, l.start_point(), l.end_point())
}

pub fn point_contains_point<T>(p1: Point<T>, p2: Point<T>) -> bool
where
T: Float + ToPrimitive,
T: Float,
{
line_euclidean_length(Line::new(p1, p2)).to_f32().unwrap() < COORD_PRECISION
}

pub fn line_string_contains_point<T>(line_string: &LineString<T>, point: Point<T>) -> bool
where
T: Float + ToPrimitive,
T: Float,
{
// LineString without points
if line_string.0.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions geo/src/algorithm/bearing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use num_traits::{Float, FromPrimitive};
use num_traits::Float;
use Point;

/// Returns the bearing to another Point in degrees.
Expand Down Expand Up @@ -30,7 +30,7 @@ pub trait Bearing<T: Float> {

impl<T> Bearing<T> for Point<T>
where
T: Float + FromPrimitive,
T: Float,
{
fn bearing(&self, point: Point<T>) -> T {
let (lng_a, lat_a) = (self.x().to_radians(), self.y().to_radians());
Expand Down
4 changes: 2 additions & 2 deletions geo/src/algorithm/contains.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use num_traits::{Float, ToPrimitive};
use num_traits::Float;

use algorithm::intersects::Intersects;
use {Coordinate, CoordinateType, Line, LineString, MultiPolygon, Point, Polygon, Rect, Triangle};
Expand Down Expand Up @@ -34,7 +34,7 @@ pub trait Contains<Rhs = Self> {

impl<T> Contains<Point<T>> for Point<T>
where
T: Float + ToPrimitive,
T: Float,
{
fn contains(&self, p: &Point<T>) -> bool {
::geo_types::private_utils::point_contains_point(*self, *p)
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 @@ -239,7 +239,7 @@ where
/// LineString-LineString distance
impl<T> EuclideanDistance<T, LineString<T>> for LineString<T>
where
T: Float + FloatConst + Signed + RTreeNum,
T: Float + Signed + RTreeNum,
{
fn euclidean_distance(&self, other: &LineString<T>) -> T {
if self.intersects(other) {
Expand Down