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 no indentation and Display formatting.

A FmtArg with Debug formatting and no indentation.

A FmtArg with alternate Display formatting and no indentation.

A FmtArg with alternate Debug formatting and no indentation.

Sets whether alternate formatting is enabled

Changes the formatting to Display.

Changes the formatting to Debug.

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.

Decrement the indentation by INDENTATION_STEP spaces.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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.