From 09b69ebd6a6fbea42fcbd342c18f92c0a19ec4a4 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 16 Feb 2019 09:15:00 -0500 Subject: [PATCH 1/2] Tweak Geometry method names slightly. - The methods take `self`, so they should be called `into_*` - Consistent with capitals and underscores - e.g. `line_string` instead of `linestring` for `LineString` --- geo-types/src/geometry.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/geo-types/src/geometry.rs b/geo-types/src/geometry.rs index b7f74ac50d..fb97a4c3b6 100644 --- a/geo-types/src/geometry.rs +++ b/geo-types/src/geometry.rs @@ -64,7 +64,7 @@ impl Geometry { /// let p2: Point = g.as_point().unwrap(); /// assert_eq!(p2, Point::new(0., 0.,)); /// ``` - pub fn as_point(self) -> Option> { + pub fn into_point(self) -> Option> { if let Geometry::Point(x) = self { Some(x) } else { @@ -73,7 +73,7 @@ impl Geometry { } /// If this Geometry is a LineString, then return that LineString, else None. - pub fn as_linestring(self) -> Option> { + pub fn into_line_string(self) -> Option> { if let Geometry::LineString(x) = self { Some(x) } else { @@ -82,7 +82,7 @@ impl Geometry { } /// If this Geometry is a Line, then return that Line, else None. - pub fn as_line(self) -> Option> { + pub fn into_line(self) -> Option> { if let Geometry::Line(x) = self { Some(x) } else { @@ -91,7 +91,7 @@ impl Geometry { } /// If this Geometry is a Polygon, then return that, else None. - pub fn as_polygon(self) -> Option> { + pub fn into_polygon(self) -> Option> { if let Geometry::Polygon(x) = self { Some(x) } else { @@ -100,7 +100,7 @@ impl Geometry { } /// If this Geometry is a MultiPoint, then return that, else None. - pub fn as_multipoint(self) -> Option> { + pub fn into_multi_point(self) -> Option> { if let Geometry::MultiPoint(x) = self { Some(x) } else { @@ -109,7 +109,7 @@ impl Geometry { } /// If this Geometry is a MultiLineString, then return that, else None. - pub fn as_multilinestring(self) -> Option> { + pub fn into_multi_line_string(self) -> Option> { if let Geometry::MultiLineString(x) = self { Some(x) } else { @@ -118,7 +118,7 @@ impl Geometry { } /// If this Geometry is a MultiPolygon, then return that, else None. - pub fn as_multipolygon(self) -> Option> { + pub fn into_multi_polygon(self) -> Option> { if let Geometry::MultiPolygon(x) = self { Some(x) } else { From 9b519c4e76549f2b41cc6e6b361d197d2c931b3b Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 16 Feb 2019 10:04:58 -0500 Subject: [PATCH 2/2] test fix --- geo-types/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geo-types/src/lib.rs b/geo-types/src/lib.rs index 89350ee554..d760becb5a 100644 --- a/geo-types/src/lib.rs +++ b/geo-types/src/lib.rs @@ -84,7 +84,7 @@ mod test { let p: Point = Point::new(0., 0.); let p1 = p.clone(); let g: Geometry = p.into(); - let p2 = g.as_point().unwrap(); + let p2 = g.into_point().unwrap(); assert_eq!(p1, p2); }