[−][src]Struct const_format::fmt::FormattingFlags
fmt
only.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(mut self: 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(mut self: Self) -> Self
[src]
Sets the formatting num_fmt to NumberFormatting::Decimal
.
This means that numbers are written as decimal.
pub const fn set_hexadecimal(mut self: Self) -> Self
[src]
Sets the formatting num_fmt to NumberFormatting::Hexadecimal
.
This means that numbers are written as hexadecimal.
pub const fn set_binary(mut self: Self) -> Self
[src]
Sets the formatting num_fmt to NumberFormatting::Binary
.
This means that numbers are written as binary.
pub const fn set_alternate(mut self: 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]
pub fn clone(&self) -> FormattingFlags
[src]
pub 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 Send for FormattingFlags
[src]
impl Sync for FormattingFlags
[src]
impl Unpin for FormattingFlags
[src]
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,
pub 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, 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.
pub 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>,