Struct const_panic::fmt::FmtArg
source · pub struct FmtArg {
pub indentation: u8,
pub is_alternate: bool,
pub fmt_kind: FmtKind,
pub number_fmt: NumberFmt,
}
Expand description
Carries all of the configuration for formatting functions.
§Example
use const_panic::{ArrayString, FmtArg, StdWrapper};
// `StdWrapper` wraps references to std types to provide their `to_panicvals` methods
const ARRAY: &[&str] = &["3", "foo\nbar", "\0qux"];
// Debug formatting
assert_eq!(
const_panic::concat_!(FmtArg::DEBUG; ARRAY),
r#"["3", "foo\nbar", "\x00qux"]"#
);
// Alternate-Debug formatting
assert_eq!(
const_panic::concat_!(FmtArg::ALT_DEBUG; ARRAY),
concat!(
"[\n",
" \"3\",\n",
" \"foo\\nbar\",\n",
" \"\\x00qux\",\n",
"]",
)
);
// Display formatting
assert_eq!(
const_panic::concat_!(FmtArg::DISPLAY; ARRAY),
"[3, foo\nbar, \x00qux]"
);
// Alternate-Display formatting
assert_eq!(
const_panic::concat_!(FmtArg::ALT_DISPLAY; ARRAY),
concat!(
"[\n",
" 3,\n",
" foo\n",
"bar,\n",
" \x00qux,\n",
"]",
)
);
Fields§
§indentation: u8
How much indentation is needed for a field/array element.
Indentation is used by fmt::Delimiter
and by fmt::Separator
,
when the is_alternate
field flag is enabled.
is_alternate: bool
Whether alternate formatting is being used.
fmt_kind: FmtKind
Whether this is intended to be Display
or Debug
formatted.
number_fmt: NumberFmt
What integers are formatted as: decimal, hexadecimal, or binary.
Implementations§
source§impl FmtArg
impl FmtArg
sourcepub const ALT_DISPLAY: Self = _
pub const ALT_DISPLAY: Self = _
A FmtArg
with alternate Display
formatting, starting with no indentation.
sourcepub const ALT_DEBUG: Self = _
pub const ALT_DEBUG: Self = _
A FmtArg
with alternate Debug
formatting, starting with no indentation.
sourcepub const ALT_BIN: Self = _
pub const ALT_BIN: Self = _
A FmtArg
with alternate Debug
and Binary
formatting,
starting with no indentation.
sourcepub const ALT_HEX: Self = _
pub const ALT_HEX: Self = _
A FmtArg
with alternate Debug
and Hexadecimal
formatting,
starting with no indentation.
sourcepub const fn set_alternate(self, is_alternate: bool) -> Self
pub const fn set_alternate(self, is_alternate: bool) -> Self
Sets whether alternate formatting is enabled
sourcepub const fn set_display(self) -> Self
pub const fn set_display(self) -> Self
Changes the formatting to Display
.
Trait Implementations§
source§impl PartialEq for FmtArg
impl PartialEq for FmtArg
impl Copy for FmtArg
impl StructuralPartialEq for FmtArg
Auto Trait Implementations§
impl Freeze for FmtArg
impl RefUnwindSafe for FmtArg
impl Send for FmtArg
impl Sync for FmtArg
impl Unpin for FmtArg
impl UnwindSafe for FmtArg
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)