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§
source§impl 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§
source§impl Clone for CustomFormat
impl Clone for CustomFormat
source§fn clone(&self) -> CustomFormat
fn clone(&self) -> CustomFormat
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for CustomFormat
impl Debug for CustomFormat
source§impl Default for CustomFormat
impl Default for CustomFormat
source§impl Format for CustomFormat
impl Format for CustomFormat
source§fn decimal(&self) -> DecimalStr<'_>
fn decimal(&self) -> DecimalStr<'_>
Returns the string representation of a decimal point.
source§fn infinity(&self) -> InfinityStr<'_>
fn infinity(&self) -> InfinityStr<'_>
Returns the string representation of an infinity symbol.
source§fn minus_sign(&self) -> MinusSignStr<'_>
fn minus_sign(&self) -> MinusSignStr<'_>
Returns the string representation of a minus sign.
source§fn plus_sign(&self) -> PlusSignStr<'_>
fn plus_sign(&self) -> PlusSignStr<'_>
Returns the string representation of a plus sign.
source§fn separator(&self) -> SeparatorStr<'_>
fn separator(&self) -> SeparatorStr<'_>
Returns the string representation of a thousands separator.
source§impl From<CustomFormat> for CustomFormatBuilder
impl From<CustomFormat> for CustomFormatBuilder
source§fn from(format: CustomFormat) -> Self
fn from(format: CustomFormat) -> Self
Converts to this type from the input type.
source§impl From<Locale> for CustomFormat
impl From<Locale> for CustomFormat
source§impl Hash for CustomFormat
impl Hash for CustomFormat
source§impl PartialEq<CustomFormat> for CustomFormat
impl PartialEq<CustomFormat> for CustomFormat
source§fn eq(&self, other: &CustomFormat) -> bool
fn eq(&self, other: &CustomFormat) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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§
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