FORMATTER

Struct FORMATTER 

Source
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>§

Source

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()
   )
Source

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

Source

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()
   )
Source

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§

Source§

impl Deref for FORMATTER

Source§

type Target = Formatter

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Formatter

Dereferences the value.
Source§

impl LazyStatic for FORMATTER

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.