Type Definition generic_str::ArrayString [−][src]
pub type ArrayString<const N: usize> = OwnedString<u8, [MaybeUninit<u8>; N]>;
Expand description
Same API as String
but without any re-allocation. Can only hold up to N
bytes
let mut s = ArrayString::<8>::new();
assert_eq!(std::mem::size_of_val(&s), 8 + 8); // 8 bytes of storage, 8 bytes for length
s.push_str("foo".into());
let t = s.clone(); // cloning requires no heap allocations
s.push_str("bar".into());
assert_eq!(t, <&str>::from("foo"));
assert_eq!(s, <&str>::from("foobar"));