For coercing between equal types that use Generic Const Expressions as arguments.
Generic Const Expressions:
const expresions that use generic parameters from the surrounding item.
To use as generic arguments, this currently requires the generic_const_exprs
unstable feature.
Example
Currently (2025-10-13),
rustc does not allow using a generic [T; N * M] where [T; M * N] is expected,
so this code:
assert_eq!;
where
:
fails to compile with this error:
error[E0308]: mismatched types
--> src/lib.rs:23:5
|
12 | generate_array_b::<N>()
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `3 * N`, found `N * 3`
|
= note: expected constant `3 * N`
found constant `N * 3`
Because the compiler can't prove that most equivalent expressions are equal,
this library provides the gce_int_eq macro for
the purpose of enabling some coercions between equal const-generic types:
use ;
assert_eq!;
where
:
the above code compiles and runs without errors. Of note is that this does not require additional bounds relative to the original code!
Reexports
This library reexports all items from typewit = "1.14.0"
No-std support
typewit_gce is #![no_std], it can be used anywhere Rust can be used.
Minimum Supported Rust Version
typewit_gce requires Rust nightly due to being made for use with the
generic_const_exprs feature.