Struct num_format::CustomFormat
source · [−]pub struct CustomFormat { /* private fields */ }
Expand description
Type for representing your own custom formats. Implements Format
.
Example
use num_format::{Buffer, Error, CustomFormat, Grouping};
fn main() -> Result<(), Error> {
let format = CustomFormat::builder()
.grouping(Grouping::Indian)
.minus_sign("🙌")
.separator("😀")
.build()?;
let mut buf = Buffer::new();
buf.write_formatted(&(-1000000), &format);
assert_eq!("🙌10😀00😀000", buf.as_str());
Ok(())
}
Implementations
sourceimpl CustomFormat
impl CustomFormat
sourcepub fn builder() -> CustomFormatBuilder
pub fn builder() -> CustomFormatBuilder
Constructs a CustomFormatBuilder
.
sourcepub fn into_builder(self) -> CustomFormatBuilder
pub fn into_builder(self) -> CustomFormatBuilder
Turns self
into a CustomFormatBuilder
.
sourcepub fn minus_sign(&self) -> &str
pub fn minus_sign(&self) -> &str
Returns this format’s representation of minus signs.
Trait Implementations
sourceimpl Clone for CustomFormat
impl Clone for CustomFormat
sourcefn clone(&self) -> CustomFormat
fn clone(&self) -> CustomFormat
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for CustomFormat
impl Debug for CustomFormat
sourceimpl Default for CustomFormat
impl Default for CustomFormat
sourceimpl Format for CustomFormat
impl Format for CustomFormat
sourcefn decimal(&self) -> DecimalStr<'_>
fn decimal(&self) -> DecimalStr<'_>
Returns the string representation of a decimal point.
sourcefn infinity(&self) -> InfinityStr<'_>
fn infinity(&self) -> InfinityStr<'_>
Returns the string representation of an infinity symbol.
sourcefn minus_sign(&self) -> MinusSignStr<'_>
fn minus_sign(&self) -> MinusSignStr<'_>
Returns the string representation of a minus sign.
sourcefn plus_sign(&self) -> PlusSignStr<'_>
fn plus_sign(&self) -> PlusSignStr<'_>
Returns the string representation of a plus sign.
sourcefn separator(&self) -> SeparatorStr<'_>
fn separator(&self) -> SeparatorStr<'_>
Returns the string representation of a thousands separator.
sourceimpl From<CustomFormat> for CustomFormatBuilder
impl From<CustomFormat> for CustomFormatBuilder
sourcefn from(format: CustomFormat) -> Self
fn from(format: CustomFormat) -> Self
Converts to this type from the input type.
sourceimpl From<Locale> for CustomFormat
impl From<Locale> for CustomFormat
sourceimpl Hash for CustomFormat
impl Hash for CustomFormat
sourceimpl PartialEq<CustomFormat> for CustomFormat
impl PartialEq<CustomFormat> for CustomFormat
sourcefn eq(&self, other: &CustomFormat) -> bool
fn eq(&self, other: &CustomFormat) -> bool
impl Eq for CustomFormat
impl StructuralEq for CustomFormat
impl StructuralPartialEq for CustomFormat
Auto Trait Implementations
impl RefUnwindSafe for CustomFormat
impl Send for CustomFormat
impl Sync for CustomFormat
impl Unpin for CustomFormat
impl UnwindSafe for CustomFormat
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more