pub enum TypeDelim {
    Tupled,
    Braced,
}
Available on crate feature non_basic only.
Expand description

Whether a struct or variant is Tupled or Braced.

Unit structs/variants are considered braced.

Example

Formatting

use const_panic::{
    fmt::{self, FmtArg, TypeDelim},
    ArrayString,
    flatten_panicvals,
};

{
    assert_eq!(
        const_panic::concat_!(FmtArg::DEBUG;
            "Foo",
            open: TypeDelim::Tupled.open(),
                10u8, fmt::COMMA_SEP,
                false, fmt::COMMA_TERM,
            close: TypeDelim::Tupled.close(),
        ),
        "Foo(10, false)"
    );
}

{
    assert_eq!(
        const_panic::concat_!(FmtArg::DEBUG;
            "Bar",
            open: TypeDelim::Braced.open(),
                "x: ", debug: "hello", fmt::COMMA_SEP,
                "y: ", true, fmt::COMMA_TERM,
            close: TypeDelim::Braced.close(),
        ),
        "Bar { x: \"hello\", y: true }"
    );
}

Variants§

§

Tupled

A Foo(Bar) type or variant

§

Braced

A Foo{bar: Baz} type or variant

Implementations§

source§

impl TypeDelim

source

pub const fn get_open_and_close(self) -> (Delimiter, Delimiter)

Gets the delimiters that surround the fields of a struct or variant.

source

pub const fn open(self) -> Delimiter

Gets the group delimiter that precedes the fields of a struct or variant.

source

pub const fn close(self) -> Delimiter

Gets the group delimiter that follows the fields of a struct or variant.

Trait Implementations§

source§

impl Clone for TypeDelim

source§

fn clone(&self) -> TypeDelim

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 PartialEq<TypeDelim> for TypeDelim

source§

fn eq(&self, other: &TypeDelim) -> 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 TypeDelim

source§

impl Eq for TypeDelim

source§

impl StructuralEq for TypeDelim

source§

impl StructuralPartialEq for TypeDelim

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.