[−][src]Struct const_format::fmt::FormattingFlags
This type bundles configuration for how to format data into strings, including.
Number formatting
How numbers are formatted in debug formatters,
It can be accessed with the num_fmt
method, and set with the set_num_fmt
method.
Each type of number formatting corresponds to a NumberFormatting
variant:
-
NumberFormatting::Decimal
(eg:formatc!("{:?}", FOO)
): formats numbers as decimal. -
NumberFormatting::Hexadecimal
(eg:formatc!("{:x}", FOO)
): formats numbers as hexadecimal. -
NumberFormatting::Binary
(eg:formatc!("{:b}", FOO)
): formats numbers as binary.
Hexadecimal or binary formatting in the formatting string from this crate imply debug formatting, and can be used to for example print an array of binary numbers.
Alternate flag
A flag that types can use to be formatted differently when it's enabled,
checked with the .is_alternate()
method.
The default behavior when it is enabled is this:
-
The Debug formater (eg:
formatc!("{:#?}", FOO)
): pretty print structs and enums. -
The hexadecimal formater (eg:
formatc!("{:#x}", FOO)
): prefixes numbers with0x
. -
The binary formater (eg:
formatc!("{:#b}", FOO)
): prefixes numbers with0b
.`
Implementations
impl FormattingFlags
[src]
pub const NEW: Self
[src]
Constructs a FormattingFlags
with these values:
-
number formatting: NumberFormatting::Decimal
-
is alternate: false
pub const fn new() -> Self
[src]
Constructs a FormattingFlags
with these values:
-
number formatting: NumberFormatting::Decimal
-
is alternate: false
pub const fn set_num_fmt(self, num_fmt: NumberFormatting) -> Self
[src]
Sets the integer formatting num_fmt,
This usually doesn't affect the outputted text in display formatting.
pub const fn set_decimal(self) -> Self
[src]
Sets the formatting num_fmt to NumberFormatting::Decimal
.
This means that numbers are written as decimal.
pub const fn set_hexadecimal(self) -> Self
[src]
Sets the formatting num_fmt to NumberFormatting::Hexadecimal
.
This means that numbers are written as hexadecimal.
pub const fn set_binary(self) -> Self
[src]
Sets the formatting num_fmt to NumberFormatting::Binary
.
This means that numbers are written as binary.
pub const fn set_alternate(self, is_alternate: bool) -> Self
[src]
Sets whether the formatting flag is enabled.
pub const fn num_fmt(self) -> NumberFormatting
[src]
Gets the current NumberFormatting
.
pub const fn is_alternate(self) -> bool
[src]
Gets whether the alternate flag is enabled
Trait Implementations
impl Clone for FormattingFlags
[src]
fn clone(&self) -> FormattingFlags
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for FormattingFlags
[src]
impl Debug for FormattingFlags
[src]
Auto Trait Implementations
impl RefUnwindSafe for FormattingFlags
impl Send for FormattingFlags
impl Sync for FormattingFlags
impl Unpin for FormattingFlags
impl UnwindSafe for FormattingFlags
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,