#[non_exhaustive]
pub enum Delimiter {
    OpenParen,
    CloseParen,
    OpenBracket,
    CloseBracket,
    OpenBrace,
    CloseBrace,
    Empty,
}
Available on crate feature 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!(
    const_panic::concat_!(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: "",
    ),
    " 100, false, [], \"really\""
);


// Alternate-Debug formatting
assert_eq!(
    const_panic::concat_!(FmtArg::ALT_DEBUG;
        open: fmt::EmptyDelimiter,
            100u8, fmt::COMMA_SEP,
            false, fmt::COMMA_SEP,
            [0u16; 0], fmt::COMMA_SEP,
            ("really"), fmt::COMMA_TERM,
        close: "",
    ),
    concat!(
        "\n",
        "    100,\n",
        "    false,\n",
        "    [],\n",
        "    \"really\",\n",
    )
);

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

OpenParen

(

§

CloseParen

)

§

OpenBracket

[

§

CloseBracket

]

§

OpenBrace

{

§

CloseBrace

}

§

Empty

An empty delimiter, exists only to add whitespace on the next line when the alternate flag is enabled.

Implementations§

source§

impl Delimiter

source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this Delimiter into an array of one PanicVal

When the alternate flag is enabled, this and the to_panicval method output:

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.

source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this Delimiter into a PanicVal

Trait Implementations§

source§

impl Clone for Delimiter

source§

fn clone(&self) -> Delimiter

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl PanicFmt for Delimiter

§

type This = Delimiter

The type after dereferencing all references. Read more
§

type Kind = IsCustomType

Whether this is a user-defined type or standard library type. Read more
source§

const PV_COUNT: usize = 1usize

The length of the array returned in Self::to_panicvals (an inherent method that formats the type for panic messages).
source§

const PROOF: IsPanicFmt<Self, Self::This, Self::Kind> = IsPanicFmt::NEW

A marker type that proves that Self implements PanicFmt. Read more
source§

impl PartialEq<Delimiter> for Delimiter

source§

fn eq(&self, other: &Delimiter) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Delimiter

source§

impl Eq for Delimiter

source§

impl StructuralEq for Delimiter

source§

impl StructuralPartialEq for Delimiter

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, W> HasTypeWitness<W> for Twhere W: MakeTypeWitness<Arg = T>, T: ?Sized,

source§

const WITNESS: W = W::MAKE

A constant of the type witness
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.