pub struct FORMATTER { /* private fields */ }Expand description
Singleton to ease use of the Formatter
assert_eq!(
address_formatter::FORMATTER
.format(hashmap!(
address_formatter::Component::City => "Toulouse",
address_formatter::Component::Country => "France",
address_formatter::Component::CountryCode => "FR",
address_formatter::Component::Road => "Rue du Médecin-Colonel Calbairac",
))
.unwrap(),
r#"Rue du Médecin-Colonel Calbairac
Toulouse
France
"#.to_owned()
);Methods from Deref<Target = Formatter>§
Sourcepub fn format(&self, into_addr: impl Into<Place>) -> Result<String, Error>
pub fn format(&self, into_addr: impl Into<Place>) -> Result<String, Error>
make a human readable text from a Place
use address_formatter::Component::*;
let formatter = address_formatter::Formatter::default();
let addr: address_formatter::Place = hashmap!(
City => "Toulouse",
Country => "France",
CountryCode => "FR",
County => "Toulouse",
HouseNumber => "17",
Neighbourhood => "Lafourguette",
Postcode => "31000",
Road => "Rue du Médecin-Colonel Calbairac",
State => "Midi-Pyrénées",
Suburb => "Toulouse Ouest",
).into();
assert_eq!(
formatter.format(addr).unwrap(),
r#"17 Rue du Médecin-Colonel Calbairac
31000 Toulouse
France
"#
.to_owned()
)Sourcepub fn format_with_config(
&self,
into_addr: impl Into<Place>,
conf: Configuration,
) -> Result<String, Error>
pub fn format_with_config( &self, into_addr: impl Into<Place>, conf: Configuration, ) -> Result<String, Error>
make a human readable text from a Place
Same as the format method,
but with a Configuration object
Sourcepub fn short_addr_format(
&self,
into_addr: impl Into<Place>,
) -> Result<String, Error>
pub fn short_addr_format( &self, into_addr: impl Into<Place>, ) -> Result<String, Error>
make a human readable short text on 1 line with only the address Place
There is basically only the housenumber and the road
use address_formatter::Component::*;
let formatter = address_formatter::Formatter::default();
let addr: address_formatter::Place = hashmap!(
City => "Toulouse",
Country => "France",
CountryCode => "FR",
County => "Toulouse",
HouseNumber => "17",
Neighbourhood => "Lafourguette",
Postcode => "31000",
Road => "Rue du Médecin-Colonel Calbairac",
State => "Midi-Pyrénées",
Suburb => "Toulouse Ouest",
).into();
assert_eq!(
formatter.short_addr_format(addr).unwrap(),
r#"17 Rue du Médecin-Colonel Calbairac"#
.to_owned()
)Sourcepub fn short_addr_format_with_config(
&self,
into_addr: impl Into<Place>,
conf: Configuration,
) -> Result<String, Error>
pub fn short_addr_format_with_config( &self, into_addr: impl Into<Place>, conf: Configuration, ) -> Result<String, Error>
make a human readable short text on 1 line with only the address Place
Same as the short_addr_format method,
but with a Configuration object
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FORMATTER
impl RefUnwindSafe for FORMATTER
impl Send for FORMATTER
impl Sync for FORMATTER
impl Unpin for FORMATTER
impl UnwindSafe for FORMATTER
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more