diff --git a/CHANGES.md b/CHANGES.md index 18538b3..e271d5e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## next release +### Changed +* impl `std::fmt::Display` for `Wkt`. + ## 0.10.0 - 2022-02-24 ### Changed * Now accepts `MULTIPOINT`s with fewer parentheses, as output by `ST_AsText` in postgis: diff --git a/src/lib.rs b/src/lib.rs index cd20119..1b6dc01 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -218,6 +218,15 @@ where } } +impl fmt::Display for Wkt +where + T: WktFloat + fmt::Debug + fmt::Display, +{ + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + self.item.fmt(formatter) + } +} + trait FromTokens: Sized + Default where T: WktFloat + FromStr + Default, @@ -336,4 +345,11 @@ mod tests { "Point(Point(Some(Coord { x: 1.0, y: 2.0, z: None, m: None })))" ); } + + #[test] + fn test_display_on_wkt() { + let wktls: Wkt = Wkt::from_str("LINESTRING(10 20, 20 30)").unwrap(); + + assert_eq!(wktls.to_string(), "LINESTRING(10 20,20 30)"); + } }