diff --git a/README.md b/README.md index 9fd0b51..5e1a06d 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,14 @@ Just run the following to add this library to your project: ```sh $ cargo add geo-uri Updating crates.io index - Adding thiserror vX.Y.Z to dependencies. + Adding geo-uri vX.Y.Z to dependencies. ``` ### Parsing -Use either the [`FromStr`](std::str::FromStr) or -[`TryFrom`](std::convert::TryFrom) traits to parse a geo URI string: +Use either the [`TryFrom`](std::convert::TryFrom) trait or the +[`parse`](str::parse) method on strings to parse a geo URI string into a +[`GeoUri`] struct: ```rust use geo_uri::GeoUri; @@ -34,8 +35,7 @@ assert_eq!(geo_uri.longitude(), 5.134); assert_eq!(geo_uri.altitude(), Some(3.6)); assert_eq!(geo_uri.uncertainty(), Some(1000.0)); -use std::str::FromStr; -let geo_uri = GeoUri::from_str("geo:52.107,5.134;u=2000.0").expect("valid geo URI"); +let geo_uri: GeoUri = "geo:52.107,5.134;u=2000.0".parse().expect("valid geo URI"); assert_eq!(geo_uri.latitude(), 52.107); assert_eq!(geo_uri.longitude(), 5.134); assert_eq!(geo_uri.altitude(), None); @@ -56,9 +56,9 @@ assert_eq!(geo_uri.uncertainty(), None); ### Generating -Use the `GeoUriBuilder` to construct a `GeoUri` struct. +Use the [`GeoUriBuilder`] to construct a [`GeoUri`] struct. Then, use either the [`ToString`](std::string::ToString) or -[`Display`](std::fmt::Display) trait to generate an geo URI string: +[`Display`](std::fmt::Display) trait to generate a geo URI string: ```rust use geo_uri::GeoUri; diff --git a/src/lib.rs b/src/lib.rs index 4209cbc..6341c7d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,7 +90,7 @@ pub enum CoordRefSystem { } impl CoordRefSystem { - /// Validates geo location coordinates against the selected coordinate reference system. + /// Validates geolocation coordinates against the selected coordinate reference system. /// /// # Examples /// @@ -155,14 +155,13 @@ impl Default for CoordRefSystem { /// # } /// ``` /// -/// or by using the [`TryFrom`] trait: +/// or by calling the [`parse`](str::parse) method on a string (using the [`TryFrom`] trait): /// ``` /// use geo_uri::GeoUri; /// # use geo_uri::Error; -/// use std::str::FromStr; /// /// # fn main() -> Result<(), Error> { -/// let geo_uri = GeoUri::from_str("geo:52.107,5.134;u=2000.0")?; +/// let geo_uri: GeoUri = "geo:52.107,5.134;u=2000.0".parse()?; /// assert_eq!(geo_uri.latitude(), 52.107); /// assert_eq!(geo_uri.longitude(), 5.134); /// assert_eq!(geo_uri.altitude(), None);