ArrayString32

Type Alias ArrayString32 

Source
pub type ArrayString32<const N: usize> = OwnedString<char, [MaybeUninit<char>; N]>;
Expand description

UTF-32 Owned String that has a fixed capacity

let mut s = ArrayString32::<8>::new();
assert_eq!(std::mem::size_of_val(&s), 8 * 4 + 8); // 8 chars of storage, 8 bytes for length

s.push_str32(&String32::from("foo"));
let t = s.clone(); // cloning requires no heap allocations
s.push_str32(&String32::from("bar"));

assert_eq!(t, String32::from("foo"));
assert_eq!(s, String32::from("foobar"));

Aliased Type§

pub struct ArrayString32<const N: usize> { /* private fields */ }

Implementations§

Source§

impl<const N: usize> ArrayString32<N>

Source

pub fn new() -> Self

Creates a new empty ArrayString.

§Examples

Basic usage:

let s = ArrayString32::<8>::new();