pub struct FormatOptions { /* private fields */ }Expand description
The default format is FormatKind::Decimal (plain decimal degrees).
When you use the alternate flag ({:#}) the default DMS variant is used.
Implementations§
Source§impl FormatOptions
impl FormatOptions
Sourcepub const fn decimal() -> Self
pub const fn decimal() -> Self
Return a FormatOptions for decimal degrees with the default precision.
Sourcepub const fn dms() -> Self
pub const fn dms() -> Self
Return a FormatOptions for degrees, minutes, seconds with the default precision.
Sourcepub const fn dms_signed() -> Self
pub const fn dms_signed() -> Self
Return a FormatOptions for signed degrees, minutes, seconds with the default precision.
Sourcepub const fn dms_labeled() -> Self
pub const fn dms_labeled() -> Self
Return a FormatOptions for labeled degrees, minutes, seconds with the default precision.
Sourcepub const fn dms_bare() -> Self
pub const fn dms_bare() -> Self
Return a FormatOptions for bare degrees, minutes, seconds with the default precision.
Sourcepub const fn with_precision(self, precision: usize) -> Self
pub const fn with_precision(self, precision: usize) -> Self
Override the number of fractional digits used when rendering.
§Examples
use lat_long::{Angle, Latitude, fmt::{FormatOptions, Formatter}};
let lat = Latitude::new(48, 51, 29.6).unwrap();
let s = lat.to_formatted_string(&FormatOptions::decimal().with_precision(2));
assert_eq!(s, "48.86");Sourcepub const fn with_default_precision(self) -> Self
pub const fn with_default_precision(self) -> Self
Set the precision to the default value for the current FormatKind.
Decimal uses DEFAULT_DECIMAL_PRECISION; every DMS variant uses
DEFAULT_DMS_PRECISION.
Sourcepub const fn with_labels(self, labels: (char, char)) -> Self
pub const fn with_labels(self, labels: (char, char)) -> Self
Set the (positive, negative) label pair used by FormatKind::DmsLabeled.
Prefer with_latitude_labels or
with_longitude_labels for the standard
N/S and E/W pairs.
Sourcepub const fn with_latitude_labels(self) -> Self
pub const fn with_latitude_labels(self) -> Self
Convenience: set labels to the latitude pair ('N', 'S').
Sourcepub const fn with_longitude_labels(self) -> Self
pub const fn with_longitude_labels(self) -> Self
Convenience: set labels to the longitude pair ('E', 'W').
Sourcepub const fn kind(&self) -> FormatKind
pub const fn kind(&self) -> FormatKind
Returns the configured FormatKind.
Sourcepub const fn is_decimal(&self) -> bool
pub const fn is_decimal(&self) -> bool
Returns true if this is a FormatKind::Decimal format.
Sourcepub const fn is_dms(&self) -> bool
pub const fn is_dms(&self) -> bool
Returns true if this is any DMS variant (signed, labeled, or bare).
Sourcepub const fn is_dms_signed(&self) -> bool
pub const fn is_dms_signed(&self) -> bool
Returns true if this is the FormatKind::DmsSigned variant.
Sourcepub const fn is_dms_labeled(&self) -> bool
pub const fn is_dms_labeled(&self) -> bool
Returns true if this is the FormatKind::DmsLabeled variant.
Sourcepub const fn is_dms_bare(&self) -> bool
pub const fn is_dms_bare(&self) -> bool
Returns true if this is the FormatKind::DmsBare variant.
Sourcepub const fn precision(&self) -> Option<usize>
pub const fn precision(&self) -> Option<usize>
Returns the configured precision, if any was set.
Sourcepub const fn labels(&self) -> Option<(char, char)>
pub const fn labels(&self) -> Option<(char, char)>
Returns the configured (positive, negative) label pair, if any.
Sourcepub fn positive_label(&self) -> Option<char>
pub fn positive_label(&self) -> Option<char>
Returns just the label used for positive values, if labels are set.
Sourcepub fn negative_label(&self) -> Option<char>
pub fn negative_label(&self) -> Option<char>
Returns just the label used for negative values, if labels are set.
Trait Implementations§
Source§impl Clone for FormatOptions
impl Clone for FormatOptions
Source§fn clone(&self) -> FormatOptions
fn clone(&self) -> FormatOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FormatOptions
impl Debug for FormatOptions
Source§impl Default for FormatOptions
impl Default for FormatOptions
Source§fn default() -> FormatOptions
fn default() -> FormatOptions
Source§impl From<FormatKind> for FormatOptions
impl From<FormatKind> for FormatOptions
Source§fn from(kind: FormatKind) -> Self
fn from(kind: FormatKind) -> Self
Source§impl Hash for FormatOptions
impl Hash for FormatOptions
Source§impl PartialEq for FormatOptions
impl PartialEq for FormatOptions
Source§fn eq(&self, other: &FormatOptions) -> bool
fn eq(&self, other: &FormatOptions) -> bool
self and other values to be equal, and is used by ==.