Rust crate for geo coord parsing https://crates.io/crates/latlon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
latlon/src/errors.rs

27 lines
674 B

use std::fmt;
use std::fmt::{Display, Formatter};
use std::num::ParseFloatError;
#[derive(Debug)]
pub(crate) struct ParseErrorInternal;
impl From<ParseFloatError> for ParseErrorInternal {
fn from(_: ParseFloatError) -> Self {
ParseErrorInternal
}
}
impl Display for ParseErrorInternal {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("Parse error")
}
}
#[derive(Debug)]
pub struct GeoParseError<T: AsRef<str> + Display>(pub T);
impl<T: AsRef<str> + Display> Display for GeoParseError<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "Error parsing coordinates from {}", self.0)
}
}