Struct stackstring::string::builder::StringBuilder [−][src]
pub struct StringBuilder<const L: usize> { /* fields omitted */ }
Expand description
A builder for the fixed-size String
. Offers pushing of single byte
s, char
s,
and byte-slices into the buffer.
let mut builder = StringBuilder::<5>::empty(); builder.push_char('a'); builder.push_char('б'); assert_eq!(builder.len(), 3); assert_eq!(builder.pop(), Some('б')); assert_eq!(builder.len(), 1); // trying to push beyond the limit is an error let err = builder.push_bytes(b"qwerty"); assert_eq!(Err(Error(7)), err); assert_eq!(builder.len(), 1); builder.push_str("bcde"); assert_eq!(builder.len(), 5); let s = builder.build(); assert_eq!(s, "abcde");