Expand description
A string with inline storage.
This consists of an integer length
field, followed immediately by the utf8 string payload.
For example, the VBox<String>
representation of "hello"
is:
Once allocated, the string size may not be modified.
Examples
use varlen::prelude::*;
use varlen::Layout;
let s = VBox::new(Str::copy("hello"));
assert_eq!(&s[..], "hello");
// Layout is as specified above:
assert_eq!(s.calculate_layout().size(), std::mem::size_of::<usize>() + 5)