From ff3d4079eb2e6aa7ed7d92d99ca9b4921a8de437 Mon Sep 17 00:00:00 2001 From: Sam Bland Date: Fri, 29 Jan 2021 05:33:46 +0000 Subject: [PATCH 1/3] Implement default coordinates --- geo-types/src/coordinate.rs | 9 +++++++++ geo-types/src/point.rs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/geo-types/src/coordinate.rs b/geo-types/src/coordinate.rs index 5c30dd751..5d80e35a3 100644 --- a/geo-types/src/coordinate.rs +++ b/geo-types/src/coordinate.rs @@ -33,6 +33,15 @@ where pub y: T, } +impl Default for Coordinate { + fn default() -> Coordinate { + Coordinate { + x: T::default(), + y: T::default(), + } + } +} + impl From<(T, T)> for Coordinate { fn from(coords: (T, T)) -> Self { Coordinate { diff --git a/geo-types/src/point.rs b/geo-types/src/point.rs index d15791c7f..4715fc7cd 100644 --- a/geo-types/src/point.rs +++ b/geo-types/src/point.rs @@ -26,7 +26,7 @@ use std::ops::{Add, Div, Mul, Neg, Sub}; /// let c = Coordinate { x: 10., y: 20. }; /// let p2: Point = c.into(); /// ``` -#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash)] +#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash, Default)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Point(pub Coordinate) where From c5260358c866112d26e1e4e85a8e121dbae9e60b Mon Sep 17 00:00:00 2001 From: Sam Bland Date: Tue, 2 Feb 2021 13:33:38 +0000 Subject: [PATCH 2/3] Update geo types changes.md --- geo-types/CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/geo-types/CHANGES.md b/geo-types/CHANGES.md index 148e831ab..cdbe32b08 100644 --- a/geo-types/CHANGES.md +++ b/geo-types/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased * Add Changes Here +* Implement Default on Coordinate struct (Defaults to (0,0)) #612 ## 0.7.0 From a26c02bd4fd3a0023e102aed0649225de9da2ecc Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 5 Feb 2021 11:32:52 -0500 Subject: [PATCH 3/3] Update geo-types/CHANGES.md --- geo-types/CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geo-types/CHANGES.md b/geo-types/CHANGES.md index cdbe32b08..58f97e400 100644 --- a/geo-types/CHANGES.md +++ b/geo-types/CHANGES.md @@ -2,8 +2,8 @@ ## Unreleased -* Add Changes Here -* Implement Default on Coordinate struct (Defaults to (0,0)) #612 +* Implement `Default` on `Coordinate` and `Point` structs (defaults to `(x: 0, y: 0)`) + * ## 0.7.0