Crate cluFullTransmute

Source
Expand description

Extended, no-constraint type transmutation API, featuring safe checks and const-ready logic.

§concat_arrays

Purpose: Combines two arrays of the same size [T; N] into a single fixed-length array [T; N*2].

use cluFullTransmute::try_transmute_or_panic;

pub const fn concat_arrays<T, const N: usize, const NDOUBLE: usize>(
	a: [T; N],
	b: [T; N],
) -> [T; NDOUBLE] {
	#[repr(C)]
	struct Pair<T, const N: usize> {
		a: [T; N],
		b: [T; N],
	}

	unsafe { try_transmute_or_panic(Pair { a, b }) }
}

fn main() {
	const A: [u8; 4] = [1, 2, 3, 4];
	const B: [u8; 4] = [5, 6, 7, 8];
	const C: [u8; 8] = concat_arrays(A, B);

	println!("{C:?}"); // [1, 2, 3, 4, 5, 6, 7, 8]
}

Modules§

contractcontract
Data Transformation TransmuteContract.
errtry_transmute
Error structure and error type with a detailed description of the cause.
memcompatible_stdapi
Basic functions for dealing with memory.
toto
A handy trait for converting any T to the desired To without directly calling crate functions.

Functions§

transmute_unchecked
Reinterprets the bits of a value of one type as another type. The function is completely const, data dimensions are not checked.
try_transmutetry_transmute
A constant function reinterprets the bits of a value of one type as another type.
try_transmute_or_panictry_transmute
A constant function reinterprets the bits of a value of one type as another type.