pub trait Formatter {
// Required method
fn format<W: Write>(&self, f: &mut W, options: &FormatOptions) -> Result;
// Provided method
fn to_formatted_string(&self, fmt: &FormatOptions) -> String { ... }
}Expand description
Common interface for writing a value to a Write target using a
FormatOptions descriptor.
Implementations exist for OrderedFloat<f64> (the underlying numeric
representation of an angle) and for each public coordinate type. Most
callers will reach for Formatter::to_formatted_string when they want
an owned String.
§Examples
use lat_long::{Angle, Longitude, fmt::{FormatOptions, Formatter}};
let lon = Longitude::new(-122, 19, 59.0).unwrap();
let bare = lon.to_formatted_string(&FormatOptions::dms_bare());
assert!(bare.starts_with('-'));Required Methods§
Provided Methods§
Sourcefn to_formatted_string(&self, fmt: &FormatOptions) -> String
fn to_formatted_string(&self, fmt: &FormatOptions) -> String
Convenience helper: render self into a new String.
This is implemented in terms of Formatter::format and a String
buffer, so it cannot fail in practice.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".