Struct const_panic::fmt::FmtArg [−][src]
#[non_exhaustive]pub struct FmtArg {
pub indentation: u8,
pub is_alternate: bool,
pub fmt_kind: FmtKind,
}
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
let array = StdWrapper(&["3", "foo\nbar", "\0qux"]);
// Debug formatting
assert_eq!(
ArrayString::<99>::from_panicvals(&array.to_panicvals(FmtArg::DEBUG)).unwrap(),
r#"["3", "foo\nbar", "\x00qux"]"#
);
// Alternate-Debug formatting
assert_eq!(
ArrayString::<99>::from_panicvals(&array.to_panicvals(FmtArg::ALT_DEBUG)).unwrap(),
concat!(
"[\n",
" \"3\",\n",
" \"foo\\nbar\",\n",
" \"\\x00qux\",\n",
"]",
)
);
// Display formatting
assert_eq!(
ArrayString::<99>::from_panicvals(&array.to_panicvals(FmtArg::DISPLAY)).unwrap(),
"[3, foo\nbar, \x00qux]"
);
// Alternate-Display formatting
assert_eq!(
ArrayString::<99>::from_panicvals(&array.to_panicvals(FmtArg::ALT_DISPLAY)).unwrap(),
concat!(
"[\n",
" 3,\n",
" foo\n",
"bar,\n",
" \x00qux,\n",
"]",
)
);
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.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.
Implementations
A FmtArg
with alternate Display
formatting and no indentation.
Sets whether alternate formatting is enabled
Changes the formatting to Display
.
This is supported on crate feature non_basic
only.
This is supported on crate feature
non_basic
only.Increments the indentation by INDENTATION_STEP
spaces.
This is supported on crate feature non_basic
only.
This is supported on crate feature
non_basic
only.Decrement the indentation by INDENTATION_STEP
spaces.