const_panic

Struct StdWrapper

Source
#[repr(transparent)]
pub struct StdWrapper<T>(pub T);
Expand description

A wrapper type used to define methods for std types.

Std types are coerced to this type through the approach used in the coerce_fmt macro.

§Example

Formatting std types with this type’s to_panicvals methods, without using macros.

use const_panic::{ArrayString, FmtArg, StdWrapper};

assert_eq!(
    ArrayString::<99>::from_panicvals(
        &StdWrapper("hello").to_panicvals(FmtArg::DEBUG)
    ).unwrap(),
    r#""hello""#
);

assert_eq!(
    ArrayString::<99>::from_panicvals(
        &StdWrapper(&[3u8, 5, 8]).to_panicvals(FmtArg::ALT_DEBUG)
    ).unwrap(),
    "[\n    3,\n    5,\n    8,\n]"
);

Tuple Fields§

§0: T

Implementations§

Source§

impl StdWrapper<&char>

Source

pub const fn to_panicvals(self, fmtarg: FmtArg) -> [PanicVal<'static>; 1]

Converts this char to a single-element PanicVal array.

Source

pub const fn to_panicval(self, fmtarg: FmtArg) -> PanicVal<'static>

Converts this char to a PanicVal.

Source§

impl StdWrapper<&u8>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this u8 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this u8 to a PanicVal.

Source§

impl StdWrapper<&u16>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this u16 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this u16 to a PanicVal.

Source§

impl StdWrapper<&u32>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this u32 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this u32 to a PanicVal.

Source§

impl StdWrapper<&u64>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this u64 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this u64 to a PanicVal.

Source§

impl StdWrapper<&u128>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this u128 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this u128 to a PanicVal.

Source§

impl StdWrapper<&usize>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this usize to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this usize to a PanicVal.

Source§

impl StdWrapper<&i8>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this i8 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this i8 to a PanicVal.

Source§

impl StdWrapper<&i16>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this i16 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this i16 to a PanicVal.

Source§

impl StdWrapper<&i32>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this i32 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this i32 to a PanicVal.

Source§

impl StdWrapper<&i64>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this i64 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this i64 to a PanicVal.

Source§

impl StdWrapper<&i128>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this i128 to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this i128 to a PanicVal.

Source§

impl StdWrapper<&isize>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Converts this isize to a single-element PanicVal array.

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Converts this isize to a PanicVal.

Source§

impl<'s> StdWrapper<&'s bool>

Source

pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]

Formats this bool into a single-PanicVal array

Source

pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>

Formats this bool into a PanicVal

Source§

impl<'a> StdWrapper<&'a str>

Source

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

Formats this &str into a single-PanicVal array

Source

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

Formats this &str into a PanicVal

Source§

impl<'s, 'a, const N: usize> StdWrapper<&'s [PanicVal<'a>; N]>

Source

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

Source§

impl<'s, 'a> StdWrapper<&'s [PanicVal<'a>]>

Source

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

Source§

impl<'a, 'b> StdWrapper<&'a &'b [PanicVal<'b>]>

Source

pub const fn deref_panic_vals(self) -> &'b [PanicVal<'b>]

Coerces a &&[PanicVal<'_>] into a &[PanicVal<'_>]

Source§

impl<'a, 'b, const N: usize> StdWrapper<&'a &'b [PanicVal<'b>; N]>

Source

pub const fn deref_panic_vals(self) -> &'b [PanicVal<'b>]

Coerces a &&[PanicVal<'_>; N] into a &[PanicVal<'_>]

Source§

impl<'b, const N: usize> StdWrapper<&'b [PanicVal<'b>; N]>

Source

pub const fn deref_panic_vals(self) -> &'b [PanicVal<'b>]

Coerces a &[PanicVal<'_>; N] into a &[PanicVal<'_>]

Source§

impl StdWrapper<&Utf8Error>

Source

pub const fn to_panicvals(self, fmtarg: FmtArg) -> [PanicVal<'static>; 5]

Formats a Utf8Error (supports both Debug and Display formatting).

Trait Implementations§

Source§

impl<T: Clone> Clone for StdWrapper<T>

Source§

fn clone(&self) -> StdWrapper<T>

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<T> PanicFmt for StdWrapper<T>
where T: PanicFmt,

Source§

const PV_COUNT: usize = T::PV_COUNT

The length of the array returned in Self::to_panicvals (an inherent method that formats the type for panic messages).
Source§

type This = StdWrapper<T>

The type after dereferencing all references. Read more
Source§

type Kind = IsCustomType

Whether this is a user-defined type or standard library type. Read more
Source§

const PROOF: IsPanicFmt<Self, Self::This, Self::Kind> = IsPanicFmt::NEW

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

impl<T: Copy> Copy for StdWrapper<T>

Auto Trait Implementations§

§

impl<T> Freeze for StdWrapper<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for StdWrapper<T>
where T: RefUnwindSafe,

§

impl<T> Send for StdWrapper<T>
where T: Send,

§

impl<T> Sync for StdWrapper<T>
where T: Sync,

§

impl<T> Unpin for StdWrapper<T>
where T: Unpin,

§

impl<T> UnwindSafe for StdWrapper<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.