cluFullTransmute

Crates.iocluFullTransmute
lib.rscluFullTransmute
version1.4.1
created_at2019-08-30 19:12:15.334215+00
updated_at2025-08-01 22:36:54.806938+00
descriptionExtended, no-constraint type transmutation API, featuring safe checks and const-ready logic.
homepage
repositoryhttps://github.com/clucompany/cluFullTransmute.git
max_upload_size
id160984
size50,268
Denis Kotlyarov (denisandroid)

documentation

README

!!! ATTENTION

  1. When converting types without checking the size of the data, you really need to understand what you are doing.
  2. You must understand the specifics of the platform you are using.

Library features

  1. Casting any type A to any type B with generic data without and with data dimension checking.
  2. Ability to use transmutation in constant functions in very old versions of rust.
  3. Possibility of delayed transmutation through contracts.
  4. Ability to work without the standard library.

Usage

Add this to your Cargo.toml:

[dependencies]
cluFullTransmute = "1.4.0"

and this to your source code:

use cluFullTransmute::try_transmute;
use cluFullTransmute::try_transmute_or_panic;
use cluFullTransmute::transmute_unchecked;

Example

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]
}
See all

License

This project has a single license (LICENSE-APACHE-2.0).

uproject  Copyright (c) 2019-2025 #UlinProject

 (Denis Kotlyarov).


Apache License

apache2  Licensed under the Apache License, Version 2.0.



Commit count: 0

cargo fmt