Struct const_format::marker_traits::IsAFormatMarker
source · pub struct IsAFormatMarker<K, T: ?Sized, R: ?Sized>(/* private fields */);
fmt
only.Expand description
Hack used to automatically wrap standard library types inside PWrapper
,
while leaving user defined types unwrapped.
Type parameters
K
is <R as FormatMarker>::Kind
The kind of type that T
is,
a slice,
other std types,
non-std types.
T
is <R as FormatMarker>::This
:
The R
type after removing all layers of references.
R
: a type that implements FormatMarker
.
Coerce Method
The coerce
method is what does the conversion from a &T
depending on
the K
type parameter:
-
IsArrayKind
: the reference is coerced to a slice, and wrapped in aPWrapper
. -
IsStdKind
: the referenced value is copied, and wrapped in aPWrapper
. -
IsNotStdKind
: the reference is simply returned as a&T
.
Implementations§
source§impl<R> IsAFormatMarker<R::Kind, R::This, R>where
R: ?Sized + FormatMarker,
impl<R> IsAFormatMarker<R::Kind, R::This, R>where
R: ?Sized + FormatMarker,
source§impl<K, T: ?Sized, R: ?Sized> IsAFormatMarker<K, T, R>
impl<K, T: ?Sized, R: ?Sized> IsAFormatMarker<K, T, R>
sourcepub const fn infer_type(self, _: &R) -> Self
pub const fn infer_type(self, _: &R) -> Self
Infers the type parameters by taking a reference to R
.
The K
and T
type parameters are determined by R
in
the NEW
associated constant.
sourcepub const fn unreference(self, r: &T) -> &T
pub const fn unreference(self, r: &T) -> &T
Removes layers of references by coercing the argument.