[][src]Macro fixed_len_str::fixed_len_str

fixed_len_str!() { /* proc-macro */ }

A macro for declare an FixedStrinput struct.

Examples

#![feature(proc_macro_hygiene, const_fn)] // this is only needed here as I expanding as a statement
 
use fixed_len_str::fixed_len_str;
 
fixed_len_str!(3);
 
let string = new_str3!("abc");
 
assert_eq!(string, "abc");
 
let string = FixedStr3::new(*b"abc");
 
assert_eq!(string, "abc");
 
let mut string = FixedStr3::default(); // equivalent to mem::zeroed but safe
string.fill_zeroes_str("abc");
 
assert_eq!(string, "abc");
 
let mut string = FixedStr3::new([b'a', b'b', 0]);
assert_eq!(string, "ab");
string.fill_zeroes_char('c');
 
assert_eq!(string, "abc");
assert_eq!(string.as_bytes(), string.as_ref().as_bytes());
assert_eq!(string.clone().into_string(), String::from(string.as_ref()));
assert_eq!(FixedStr3::from_vec(Vec::new()).as_ref(), "");