#[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>
impl StdWrapper<&char>
Sourcepub const fn to_panicvals(self, fmtarg: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, fmtarg: FmtArg) -> [PanicVal<'static>; 1]
Converts this char
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, fmtarg: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, fmtarg: FmtArg) -> PanicVal<'static>
Converts this char
to a PanicVal
.
Source§impl StdWrapper<&u8>
impl StdWrapper<&u8>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this u8
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this u8
to a PanicVal
.
Source§impl StdWrapper<&u16>
impl StdWrapper<&u16>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this u16
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this u16
to a PanicVal
.
Source§impl StdWrapper<&u32>
impl StdWrapper<&u32>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this u32
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this u32
to a PanicVal
.
Source§impl StdWrapper<&u64>
impl StdWrapper<&u64>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this u64
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this u64
to a PanicVal
.
Source§impl StdWrapper<&u128>
impl StdWrapper<&u128>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this u128
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this u128
to a PanicVal
.
Source§impl StdWrapper<&usize>
impl StdWrapper<&usize>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this usize
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this usize
to a PanicVal
.
Source§impl StdWrapper<&i8>
impl StdWrapper<&i8>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this i8
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this i8
to a PanicVal
.
Source§impl StdWrapper<&i16>
impl StdWrapper<&i16>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this i16
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this i16
to a PanicVal
.
Source§impl StdWrapper<&i32>
impl StdWrapper<&i32>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this i32
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this i32
to a PanicVal
.
Source§impl StdWrapper<&i64>
impl StdWrapper<&i64>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this i64
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this i64
to a PanicVal
.
Source§impl StdWrapper<&i128>
impl StdWrapper<&i128>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this i128
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this i128
to a PanicVal
.
Source§impl StdWrapper<&isize>
impl StdWrapper<&isize>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Converts this isize
to a single-element PanicVal
array.
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Converts this isize
to a PanicVal
.
Source§impl<'s> StdWrapper<&'s bool>
impl<'s> StdWrapper<&'s bool>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'static>; 1]
Formats this bool
into a single-PanicVal
array
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
pub const fn to_panicval(self, f: FmtArg) -> PanicVal<'static>
Formats this bool
into a PanicVal
Source§impl<'a> StdWrapper<&'a str>
impl<'a> StdWrapper<&'a str>
Sourcepub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'a>; 1]
pub const fn to_panicvals(self, f: FmtArg) -> [PanicVal<'a>; 1]
Formats this &str
into a single-PanicVal
array
Sourcepub const fn to_panicval(self, f: FmtArg) -> PanicVal<'a>
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]>
impl<'s, 'a, const N: usize> StdWrapper<&'s [PanicVal<'a>; N]>
Sourcepub const fn to_panicvals(self, _: FmtArg) -> &'s [PanicVal<'a>; N]
pub const fn to_panicvals(self, _: FmtArg) -> &'s [PanicVal<'a>; N]
Source§impl<'s, 'a> StdWrapper<&'s [PanicVal<'a>]>
impl<'s, 'a> StdWrapper<&'s [PanicVal<'a>]>
Sourcepub const fn to_panicvals(self, _: FmtArg) -> &'s [PanicVal<'a>]
pub const fn to_panicvals(self, _: FmtArg) -> &'s [PanicVal<'a>]
Source§impl<'a, 'b> StdWrapper<&'a &'b [PanicVal<'b>]>
impl<'a, 'b> StdWrapper<&'a &'b [PanicVal<'b>]>
Sourcepub const fn deref_panic_vals(self) -> &'b [PanicVal<'b>]
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]>
impl<'a, 'b, const N: usize> StdWrapper<&'a &'b [PanicVal<'b>; N]>
Sourcepub const fn deref_panic_vals(self) -> &'b [PanicVal<'b>]
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]>
impl<'b, const N: usize> StdWrapper<&'b [PanicVal<'b>; N]>
Sourcepub const fn deref_panic_vals(self) -> &'b [PanicVal<'b>]
pub const fn deref_panic_vals(self) -> &'b [PanicVal<'b>]
Coerces a &[PanicVal<'_>; N]
into a &[PanicVal<'_>]
Source§impl StdWrapper<&Utf8Error>
impl StdWrapper<&Utf8Error>
Sourcepub const fn to_panicvals(self, fmtarg: FmtArg) -> [PanicVal<'static>; 5]
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>
impl<T: Clone> Clone for StdWrapper<T>
Source§fn clone(&self) -> StdWrapper<T>
fn clone(&self) -> StdWrapper<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> PanicFmt for StdWrapper<T>where
T: PanicFmt,
impl<T> PanicFmt for StdWrapper<T>where
T: PanicFmt,
Source§const PV_COUNT: usize = T::PV_COUNT
const PV_COUNT: usize = T::PV_COUNT
Self::to_panicvals
(an inherent method that formats the type for panic messages).