Struct const_panic::fmt::FmtArg[][src]

pub struct FmtArg {
    pub indentation: u8,
    pub is_alternate: bool,
    pub fmt_kind: FmtKind,
    pub number_fmt: NumberFmt,
}
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

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.

number_fmt: NumberFmt

What integers are formatted as: decimal, hexadecimal, or binary.

Implementations

This is supported on crate feature non_basic only.

Converts this FmtArg into a PackedFmtArg, which is smaller but can only be converted back into a FmtArg.

A FmtArg with no indentation and Display formatting.

A FmtArg with alternate Display formatting, starting with no indentation.

A FmtArg with Debug formatting and no indentation.

A FmtArg with alternate Debug formatting, starting with no indentation.

A FmtArg with Debug and Binary formatting and no indentation.

A FmtArg with alternate Debug and Binary formatting, starting with no indentation.

A FmtArg with Debug and Hexadecimal formatting and no indentation.

A FmtArg with alternate Debug and Hexadecimal formatting, starting with no indentation.

Sets whether alternate formatting is enabled

Changes the formatting to Display.

Changes the formatting to Debug.

Changes the formatting to Debug, and number formatting to Hexadecimal.

Changes the formatting to Debug, and number formatting to Binary.

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.