Crate stackstring

Crate stackstring 

Source
Expand description

A fixed-size inline string implementation, meant for simple use cases.

String is backed by an array of size L and the string can have a length of up to L bytes, and will be space-padded if length is less than L.

§Example usage

use stackstring::String;

let s1 = String::<5>::try_from("abcde").unwrap();
dbg!(s1); // just like a normal string

// can be init from raw bytes
let _s2 = String::<5>::from(*b"abcde");
// or
let s2 = String::<5>::from(b"abcde");
dbg!(s2);

let s3 = String::<5>::try_from_str_padded("abc").unwrap();
assert_eq!(s3, "abc  ");

let s4 = String::<6>::from_other(s3);
assert_eq!(s4, "abc   ");

// the opposite will result in a compile error, however
// let s5 = String::<3>::from_other(s4);

Re-exports§

pub use string::String;
pub use string::builder::StringBuilder;

Modules§

error
string