As Repr
Rust trait for constant #[repr(T)] conversions
Check out the documentation for examples.
Features
- Const trait workaround for stable Rust exposing a safe transmute to the
reprtype with a trait - Optionally-enabled const trait workarounds for generic integer and float
operations and comparisons on the inherent representation
inherent: ProvidingAsReprInherentbuilt onAsReprbut chooses a specific representation to interpret as for const operationscmp: Providing const fns generic for comparable typesfloat: Providing const fns generic for floating point typesint: Providing const fns generic for integer typesnum: Providing const fns generic for numeric types (floats and ints)ops: Providing const fns generic for mathematical types (numeric types andDurations)
MSRV
The current MSRV is Rust 1.91.
Any future MSRV updates will follow the Ardaku MSRV guidelines.
License
Copyright © 2025-2026 The As Repr Contributors.
Licensed under any of
- Apache License, Version 2.0, (LICENSE_APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- Boost Software License, Version 1.0, (LICENSE_BOOST or https://www.boost.org/LICENSE_1_0.txt)
- MIT License, (LICENSE_MIT or https://mit-license.org/)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as described above, without any additional terms or conditions.
AI / LLM (Non-)Usage
This project was developed without using AI tooling. AI usage for contributions is strictly banned, with the exception of AI tooling trained on exclusively CC0, Unlicense, or equivalently-licensed code. By opening a PR on this repository, you assert that the work (excluding any test data) is either human generated, computer generated trained on works in the public domain, or a combination of the two. AI bug reports are welcome as issues, as long as there is a disclaimer that it was discovered with AI.
Help
If you want help using or contributing to this library, feel free to send me an email at aldaronlau@gmail.com.