Function constmuck::wrapper::peel [−][src]
pub const fn peel<Inner, Outer>(
val: Outer,
_: ImplsTransparentWrapper<Outer, Inner>
) -> Inner
Expand description
Casts Outer
to Inner
Requires that Outer
implements
TransparentWrapper<Inner>
Example
use constmuck::{infer_tw, wrapper};
use std::num::Wrapping;
// `infer_tw!()` is a more concise way to write `ImplsTransparentWrapper::NEW`
const VALUE: u32 = wrapper::peel(Wrapping(3), infer_tw!());
// Casting `[Wrapping<u32>; 3]` to `[u32; 3]`
//
// The `.array()` is required to cast arrays of wrappers into
// arrays of the values inside those wrappers.
const ARR: [u32; 3] = wrapper::peel(
[Wrapping(5), Wrapping(8), Wrapping(13)],
infer_tw!().array(),
);
assert_eq!(VALUE, 3);
assert_eq!(ARR, [5, 8, 13]);