Enum const_panic::fmt::Delimiter[][src]

#[non_exhaustive]
pub enum Delimiter {
    OpenParen,
    CloseParen,
    OpenBracket,
    CloseBracket,
    OpenBrace,
    CloseBrace,
    Empty,
}
This is supported 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!(
    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
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

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.

Converts this Delimiter into a PanicVal

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The type after dereferencing all references. Read more

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

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.