Struct const_panic::PanicVal

source ·
pub struct PanicVal<'a> { /* private fields */ }
Expand description

An opaque enum of the values that this crate knows how to format, along with some formatting metadata.

This has constructor functions to make a PanicVal from:

  • bool
  • Integers
  • &str
  • Arrays/Slices of primitives (with the “non_basic” feature, enabled by default)
  • ShortString (with the “non_basic” feature, enabled by default)

Implementations§

source§

impl<'a> PanicVal<'a>

source

pub const fn from_short_str(this: ShortString, f: FmtArg) -> PanicVal<'a>

Constructs a PanicVal from a ShortString.

source§

impl PanicVal<'_>

source

pub const fn from_char(c: char, fmtarg: FmtArg) -> Self

Constructs a PanicVal from a char.

source§

impl<'a> PanicVal<'a>

source

pub const EMPTY: Self = _

A PanicVal that formats to nothing.

source

pub const fn leftpad(&self) -> u8

How many spaces are printed before this

source

pub const fn rightpad(&self) -> u8

How many spaces are printed after this

source§

impl<'a> PanicVal<'a>

source

pub const fn with_leftpad(self, fmtarg: FmtArg) -> Self

Sets the amount of spaces printed before this to fmtarg.indentation.

Note that only strings can be padded.

source

pub const fn with_rightpad(self, fmtarg: FmtArg) -> Self

Sets the amount of spaces printed after this to fmtarg.indentation.

Note that only strings can be padded.

source

pub const fn write_str(string: &'a str) -> Self

Constructs a PanicVal which outputs the contents of string verbatim.

Equivalent to PanicVal::from_str(string, FmtArg::DISPLAY)

source

pub const fn write_short_str(string: ShortString) -> Self

Constructs a PanicVal from a ShortString, which outputs the string verbatim.

source

pub const fn from_element_separator( separator: &str, is_last_field: IsLast, fmtarg: FmtArg ) -> Self

Constructs a PanicVal usable as a separator between fields or elements.

This is sensitive to the fmtarg.is_alternate flag, for more details on that you can look at the docs for Separator::to_panicval

Panics

This panics if string.len() is greater than 12.

source§

impl<'a> PanicVal<'a>

source

pub const fn to_panicvals(&self, _: FmtArg) -> [PanicVal<'a>; 1]

Wraps this PanicVal in a single-element array.

source

pub const fn to_panicval(&self, _: FmtArg) -> PanicVal<'a>

Returns a copy of this PanicVal.

source§

impl<'s> PanicVal<'s>

source

pub const fn from_slice_u8(this: &'s [u8], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_u16(this: &'s [u16], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_u32(this: &'s [u32], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_u64(this: &'s [u64], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_u128(this: &'s [u128], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_usize(this: &'s [usize], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_i8(this: &'s [i8], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_i16(this: &'s [i16], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_i32(this: &'s [i32], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_i64(this: &'s [i64], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_i128(this: &'s [i128], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_isize(this: &'s [isize], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_bool(this: &'s [bool], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_char(this: &'s [char], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source

pub const fn from_slice_str(this: &'s [&'s str], fmtarg: FmtArg) -> PanicVal<'s>

Available on crate feature non_basic only.

Constructs a PanicVal from a slice.

source§

impl PanicVal<'_>

source

pub const fn from_u8(this: u8, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_u16(this: u16, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_u32(this: u32, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_u64(this: u64, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_u128(this: u128, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_usize(this: usize, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_i8(this: i8, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_i16(this: i16, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_i32(this: i32, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_i64(this: i64, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_i128(this: i128, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_isize(this: isize, f: FmtArg) -> PanicVal<'static>

Constructs this PanicVal from an integer.

source§

impl PanicVal<'_>

source

pub const fn from_bool(this: bool, _f: FmtArg) -> PanicVal<'static>

Constructs a PanicVal from a bool .

source§

impl<'a> PanicVal<'a>

source

pub const fn from_str(this: &'a str, f: FmtArg) -> PanicVal<'a>

Constructs a PanicVal from a &str

Trait Implementations§

source§

impl<'a> Clone for PanicVal<'a>

source§

fn clone(&self) -> PanicVal<'a>

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 PanicVal<'_>

§

type This = PanicVal<'_>

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<'a> Copy for PanicVal<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for PanicVal<'a>

§

impl<'a> Send for PanicVal<'a>

§

impl<'a> Sync for PanicVal<'a>

§

impl<'a> Unpin for PanicVal<'a>

§

impl<'a> UnwindSafe for PanicVal<'a>

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.