Bytification utilities
This crate provides a simple macro that can take multiple const-expr values as an input and merge them all together into a continuous byte array at compile-time. Supports all primitive types and is #[no_std] compatible.
use bytify;
const CAKE: char = '🎂';
assert_eq!;
Supported types
All primitive types (as literals or any other const-expr values) as well as [u8; N] and &[u8] values.
- Unsuffixed numbers are inferred to be
i32for integers andf64for floats. boolvalues are cast tou8.- UTF-8 encoding is used to write
strandcharvalues.
Endianness
bytify! always writes data using current target's native endianness.
To switch to little/big endianness use bytify_le! or bytify_be! respectively.
use ;
assert_eq!;
assert_eq!;
Constants and statics
use bytify;
bytify!;
assert_eq!;