Function constmuck::copying::copy[][src]

pub const fn copy<T, const SIZE: usize>(
    reff: &T,
    bounds: TypeSize<ImplsCopy<T>, T, SIZE>
) -> T
Expand description

Copies a T from a &T

Requires that T implements Copy + Pod (see ImplsCopy docs for why it requires Pod)

Example

Making a pair function.

use constmuck::{copying, type_size};
use constmuck::{ImplsCopy, TypeSize};

const fn pair<T, const SIZE: usize>(
    reff: &T,
    bounds: TypeSize<ImplsCopy<T>, T, SIZE>
) -> [T; 2] {
    [copying::copy(reff, bounds), copying::copy(reff, bounds)]
}

const PAIR_U8: [u8; 2] = pair(&128, type_size!(u8));

assert_eq!(PAIR_U8, [128, 128]);