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§
- contract
contract - Data Transformation TransmuteContract.
- err
try_transmute - Error structure and error type with a detailed description of the cause.
- mem
compatible_stdapi - Basic functions for dealing with memory.
- to
to - A handy trait for converting any
Tto the desiredTowithout 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_
transmute ⚠try_transmute - A constant function reinterprets the bits of a value of one type as another type.
- try_
transmute_ ⚠or_ panic try_transmute - A constant function reinterprets the bits of a value of one type as another type.