Struct const_panic::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<'_>]

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,

§

type This = StdWrapper<T>

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 = T::PV_COUNT

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<T: Copy> Copy for StdWrapper<T>

Auto Trait Implementations§

§

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> 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>,

§

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>,

§

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.