Fix typos and improve examples
This commit is contained in:
parent
7f3d4128b8
commit
8ad3d5dea7
14
README.md
14
README.md
|
@ -17,13 +17,14 @@ Just run the following to add this library to your project:
|
||||||
```sh
|
```sh
|
||||||
$ cargo add geo-uri
|
$ cargo add geo-uri
|
||||||
Updating crates.io index
|
Updating crates.io index
|
||||||
Adding thiserror vX.Y.Z to dependencies.
|
Adding geo-uri vX.Y.Z to dependencies.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parsing
|
### Parsing
|
||||||
|
|
||||||
Use either the [`FromStr`](std::str::FromStr) or
|
Use either the [`TryFrom`](std::convert::TryFrom) trait or the
|
||||||
[`TryFrom`](std::convert::TryFrom) traits to parse a geo URI string:
|
[`parse`](str::parse) method on strings to parse a geo URI string into a
|
||||||
|
[`GeoUri`] struct:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use geo_uri::GeoUri;
|
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.altitude(), Some(3.6));
|
||||||
assert_eq!(geo_uri.uncertainty(), Some(1000.0));
|
assert_eq!(geo_uri.uncertainty(), Some(1000.0));
|
||||||
|
|
||||||
use std::str::FromStr;
|
let geo_uri: GeoUri = "geo:52.107,5.134;u=2000.0".parse().expect("valid geo URI");
|
||||||
let geo_uri = GeoUri::from_str("geo:52.107,5.134;u=2000.0").expect("valid geo URI");
|
|
||||||
assert_eq!(geo_uri.latitude(), 52.107);
|
assert_eq!(geo_uri.latitude(), 52.107);
|
||||||
assert_eq!(geo_uri.longitude(), 5.134);
|
assert_eq!(geo_uri.longitude(), 5.134);
|
||||||
assert_eq!(geo_uri.altitude(), None);
|
assert_eq!(geo_uri.altitude(), None);
|
||||||
|
@ -56,9 +56,9 @@ assert_eq!(geo_uri.uncertainty(), None);
|
||||||
|
|
||||||
### Generating
|
### 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
|
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
|
```rust
|
||||||
use geo_uri::GeoUri;
|
use geo_uri::GeoUri;
|
||||||
|
|
|
@ -90,7 +90,7 @@ pub enum CoordRefSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CoordRefSystem {
|
impl CoordRefSystem {
|
||||||
/// Validates geo location coordinates against the selected coordinate reference system.
|
/// Validates geolocation coordinates against the selected coordinate reference system.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # 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::GeoUri;
|
||||||
/// # use geo_uri::Error;
|
/// # use geo_uri::Error;
|
||||||
/// use std::str::FromStr;
|
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Error> {
|
/// # 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.latitude(), 52.107);
|
||||||
/// assert_eq!(geo_uri.longitude(), 5.134);
|
/// assert_eq!(geo_uri.longitude(), 5.134);
|
||||||
/// assert_eq!(geo_uri.altitude(), None);
|
/// assert_eq!(geo_uri.altitude(), None);
|
||||||
|
|
Loading…
Reference in New Issue