size-trait
This crate provides traits for restricting the size of type parameters.
Example
Zero-sized types
use ZeroSize;
// This struct can only contain `T` when `T` has a size of 0.
;
let _ = Zst;
let _ = Zst;
Fixed-sized types
use Size;
// This struct can only contain `T` when `T` has a size of 4 bytes.
;
let _ = Fixed4Bytes;
let _ = Fixed4Bytes;
Warning
This crate relies on the unstable feature generic_const_exprs. This feature is only available on nightly Rust. It is also not guaranteed to be stable in the future. Tracking issue #76560.
In order for this crate to work properly, you must enable the generic_const_exprs feature in your crate:
Author
- Jacob Lindahl @sudo_build geeklaunch.io