autosized-num
Auto-sized integer macros: choose the smallest signed/unsigned type for a literal at compile time.
features
Features
-
Auto-sized integer macros
Automatically choose the smallest fitting integer type for a literal. -
Unsigned support
auto_sized_unsigned!/auto_sized_unsigned_val!→ expands tou8,u16,u32,u64, oru128. -
Signed support
auto_sized_signed!/auto_sized_signed_val!→ expands toi8,i16,i32,i64, ori128. -
Unified macros
auto_sized_int!/auto_sized_int_val!→ automatically pick signed or unsigned depending on the literal.
Accepts the fulli128range. -
Type and value variants
*_unsigned!,*_signed!,*_int!→ return a type.*_valvariants → return a value with an explicit cast.
-
no_std friendly
Expanded code uses only primitive integer types, so it works inno_stdenvironments.
Usage
Add the crate with Cargo:
Then import the macros and use them in your code:
use *;
Notes
auto_sized_int!/auto_sized_int_val!accept the fulli128range.- The macros expand to primitive integer types only, so they are fully usable in
no_stdenvironments.
Crate Info
- License: MIT OR Apache-2.0
- Crate: autosized-num on crates.io
- Docs: docs.rs/autosized-num
- Repository: GitHub