Crate const_stringify_ints

Source
Expand description

This library solves a very specific problem: You have a (possibly generic) constant integer, and you want it as a &'static str.

All methods are named const_str_ and then the type.

use const_stringify_ints::*;

const SIZE_OF_MY_ARR:usize = 294;
const SIZE_STR:&'static str = const_str_usize::<SIZE_OF_MY_ARR>();

assert_eq!(SIZE_OF_MY_ARR.to_string().as_str(), SIZE_STR);

§Support

This library supports no_std environments.

This library should in theory support targets with a 16-bit, however I don’t have a way of testing this. Additionaly, these targets are likely very memory-constrained, and this crate always ‘allocates’ 5 bytes of static memory for a u16 even when only 1 byte is needed.

Functions§

const_str_i8
Returns the const parameter N as a &'static str.
const_str_i16
Returns the const parameter N as a &'static str.
const_str_i32
Returns the const parameter N as a &'static str.
const_str_i64
Returns the const parameter N as a &'static str.
const_str_i128
Returns the const parameter N as a &'static str.
const_str_isize
Returns the const parameter N as a &'static str.
const_str_u8
Returns the const parameter N as a &'static str.
const_str_u16
Returns the const parameter N as a &'static str.
const_str_u32
Returns the const parameter N as a &'static str.
const_str_u64
Returns the const parameter N as a &'static str.
const_str_u128
Returns the const parameter N as a &'static str.
const_str_usize
Returns the const parameter N as a &'static str.