Enum const_panic::fmt::Delimiter [−][src]
#[non_exhaustive]
pub enum Delimiter {
OpenParen,
CloseParen,
OpenBracket,
CloseBracket,
OpenBrace,
CloseBrace,
Empty,
}
non_basic
only.Expand description
For outputting an alternate flag-aware delimiter.
This was created for formatting structs and enum variants,
so these delimiters have spaces around them to follow the
Foo { bar: baz }
, Foo(bar)
, and [foo, bar]
style.
Example
use const_panic::{
fmt::{self, FmtArg},
ArrayString,
flatten_panicvals,
};
// Debug formatting
assert_eq!(
ArrayString::<999>::from_panicvals(
&flatten_panicvals!(FmtArg::DEBUG;
open: fmt::EmptyDelimiter,
100u8, fmt::COMMA_SEP,
false, fmt::COMMA_SEP,
[0u16; 0], fmt::COMMA_SEP,
// parenthesizing to pass this as a non-literal
// otherwise the string is Display formatted
("really"), fmt::COMMA_TERM,
close: "",
)
).unwrap(),
" 100, false, [], \"really\""
);
// Alternate-Debug formatting
assert_eq!(
ArrayString::<999>::from_panicvals(
&flatten_panicvals!(FmtArg::ALT_DEBUG;
open: fmt::EmptyDelimiter,
100u8, fmt::COMMA_SEP,
false, fmt::COMMA_SEP,
[0u16; 0], fmt::COMMA_SEP,
("really"), fmt::COMMA_TERM,
close: "",
)
).unwrap(),
concat!(
"\n",
" 100,\n",
" false,\n",
" [],\n",
" \"really\",\n",
)
);
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
(
)
[
]
{
}
An empty delimiter, exists only to add whitespace on the next line when the alternate flag is enabled.
Implementations
Converts this Delimiter
into an array of one PanicVal
When the alternate flag is enabled, this and the to_panicval
method output:
- the delimiter
- a newline
- fmtarg.indentation amount of spaces
When the alternate flag is disabled, these methods output braces with spaces around them, the empty delimiter as one space, and the remaining delimiters with no spaces around them.
Converts this Delimiter
into a PanicVal
Trait Implementations
type Kind = IsCustomType
type Kind = IsCustomType
Whether this is a user-defined type or standard library type. Read more
The length of the array returned in Self::to_panicvals
(an inherent method that formats the type for panic messages). Read more