Skip to content

Commit b3d4eb4

Browse files
committed
chore(rstar): Get rid of unnecessary trait bounds
1 parent 41e00b4 commit b3d4eb4

6 files changed

Lines changed: 27 additions & 35 deletions

File tree

rstar/src/aabb.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ use serde::{Deserialize, Serialize};
2020
/// type will result in an n-dimensional bounding box.
2121
#[derive(Clone, Debug, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
2222
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
23-
pub struct AABB<P>
24-
where
25-
P: Point,
26-
{
23+
pub struct AABB<P> {
2724
lower: P,
2825
upper: P,
2926
}
3027

3128
impl<P> AABB<P>
3229
where
33-
P: Point,
30+
P: Clone,
3431
{
3532
/// Returns the AABB encompassing a single point.
3633
pub fn from_point(p: P) -> Self {
@@ -55,7 +52,12 @@ where
5552
pub fn upper(&self) -> P {
5653
self.upper.clone()
5754
}
55+
}
5856

57+
impl<P> AABB<P>
58+
where
59+
P: Point,
60+
{
5961
/// Creates a new AABB encompassing two points.
6062
pub fn from_corners(p1: P, p2: P) -> Self {
6163
Self {

rstar/src/point.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ pub trait PointExt: Point {
269269
}
270270

271271
#[inline]
272-
pub fn min_inline<S>(a: S, b: S) -> S
272+
pub(crate) fn min_inline<S>(a: S, b: S) -> S
273273
where
274-
S: RTreeNum,
274+
S: PartialOrd,
275275
{
276276
if a < b {
277277
a
@@ -281,9 +281,9 @@ where
281281
}
282282

283283
#[inline]
284-
pub fn max_inline<S>(a: S, b: S) -> S
284+
pub(crate) fn max_inline<S>(a: S, b: S) -> S
285285
where
286-
S: RTreeNum,
286+
S: PartialOrd,
287287
{
288288
if a > b {
289289
a

rstar/src/primitives/geom_with_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{envelope::Envelope, object::Distance};
3131
/// ```
3232
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
3333
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
34-
pub struct GeomWithData<R: RTreeObject, T> {
34+
pub struct GeomWithData<R, T> {
3535
geom: R,
3636
/// Data to be associated with the geometry being stored in the [`RTree`](crate::RTree).
3737
pub data: T,
@@ -63,7 +63,7 @@ impl<R: PointDistance, T> PointDistance for GeomWithData<R, T> {
6363
}
6464
}
6565

66-
impl<R: RTreeObject, T> GeomWithData<R, T> {
66+
impl<R, T> GeomWithData<R, T> {
6767
/// Create a new [GeomWithData] struct using the provided geometry and data.
6868
pub fn new(geom: R, data: T) -> Self {
6969
Self { geom, data }

rstar/src/primitives/line.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,14 @@ use num_traits::{One, Zero};
2424
/// ```
2525
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
2626
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
27-
pub struct Line<P>
28-
where
29-
P: Point,
30-
{
27+
pub struct Line<P> {
3128
/// The line's start point
3229
pub from: P,
3330
/// The line's end point.
3431
pub to: P,
3532
}
3633

37-
impl<P> Line<P>
38-
where
39-
P: Point,
40-
{
34+
impl<P> Line<P> {
4135
/// Creates a new line between two points.
4236
pub fn new(from: P, to: P) -> Self {
4337
Line { from, to }

rstar/src/primitives/object_ref.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use core::ops::Deref;
1212
/// **Note:** the wrapper implements [RTreeObject] and referenced object `T` can be
1313
/// accessed via an implementation of `Deref<Target=T>`.
1414
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
15-
pub struct ObjectRef<'a, T: RTreeObject> {
15+
pub struct ObjectRef<'a, T> {
1616
inner: &'a T,
1717
}
1818

@@ -43,14 +43,14 @@ impl<T: PointDistance> PointDistance for ObjectRef<'_, T> {
4343
}
4444
}
4545

46-
impl<'a, T: RTreeObject> ObjectRef<'a, T> {
46+
impl<'a, T> ObjectRef<'a, T> {
4747
/// Create a new [ObjectRef] struct using the object.
4848
pub fn new(inner: &'a T) -> Self {
4949
Self { inner }
5050
}
5151
}
5252

53-
impl<T: RTreeObject> Deref for ObjectRef<'_, T> {
53+
impl<T> Deref for ObjectRef<'_, T> {
5454
type Target = T;
5555

5656
fn deref(&self) -> &Self::Target {

rstar/src/primitives/rectangle.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,26 @@ use crate::{aabb::AABB, object::Distance};
1414
/// `P`: The rectangle's [Point] type.
1515
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
1616
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17-
pub struct Rectangle<P>
18-
where
19-
P: Point,
20-
{
17+
pub struct Rectangle<P> {
2118
aabb: AABB<P>,
2219
}
2320

24-
impl<P> Rectangle<P>
25-
where
26-
P: Point,
27-
{
21+
impl<P> Rectangle<P> {
2822
/// Creates a new rectangle defined by two corners.
29-
pub fn from_corners(corner_1: P, corner_2: P) -> Self {
23+
pub fn from_corners(corner_1: P, corner_2: P) -> Self
24+
where
25+
P: Point,
26+
{
3027
AABB::from_corners(corner_1, corner_2).into()
3128
}
3229

3330
/// Creates a new rectangle defined by it's [axis aligned bounding box(AABB).
3431
pub fn from_aabb(aabb: AABB<P>) -> Self {
3532
Rectangle { aabb }
3633
}
34+
}
3735

36+
impl<P: Clone> Rectangle<P> {
3837
/// Returns the rectangle's lower corner.
3938
///
4039
/// This is the point contained within the rectangle with the smallest coordinate value in each
@@ -52,10 +51,7 @@ where
5251
}
5352
}
5453

55-
impl<P> From<AABB<P>> for Rectangle<P>
56-
where
57-
P: Point,
58-
{
54+
impl<P> From<AABB<P>> for Rectangle<P> {
5955
fn from(aabb: AABB<P>) -> Self {
6056
Self::from_aabb(aabb)
6157
}

0 commit comments

Comments
 (0)