pub struct CheetahBuilder { /* private fields */ }Expand description
Append-heavy builder for constructing Cheetah string values.
CheetahBuilder keeps mutable construction separate from immutable,
clone-cheap CheetahString values.
A builder created with new or with a capacity of at most 23
bytes keeps its contents on the stack until they outgrow inline storage,
so building a short key and calling finish allocates
nothing. A larger with_capacity allocates that
capacity up front, as String::with_capacity does.
Implementations§
Source§impl CheetahBuilder
impl CheetahBuilder
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty builder with room for at least capacity bytes.
Up to 23 bytes fit inline without allocating; a larger capacity is allocated immediately.
Sourcepub fn from_string(value: String) -> Self
pub fn from_string(value: String) -> Self
Creates a builder from existing owned storage.
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more bytes.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity in bytes: 23 while the contents are inline, otherwise the allocated capacity.
Sourcepub fn finish(self) -> CheetahString
pub fn finish(self) -> CheetahString
Freezes this builder into the canonical clone-cheap string value.
Inline contents become an inline value without allocating. Use
CheetahBuilder::into_string when construction is followed by more
mutation or when spare capacity must be retained.
Sourcepub fn finish_string(self) -> CheetahString
👎Deprecated since 3.0.0: use finish()
pub fn finish_string(self) -> CheetahString
use finish()
Freezes the builder into the canonical clone-cheap string value.
This compatibility name is retained so downstream v2 consumers can adopt the immutable v3 core without a source migration.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Returns the contents as an owned String.
Heap contents are returned without copying, keeping their spare
capacity; inline contents are copied into a new String.
Trait Implementations§
Source§impl Clone for CheetahBuilder
impl Clone for CheetahBuilder
Source§impl Debug for CheetahBuilder
impl Debug for CheetahBuilder
Source§impl Default for CheetahBuilder
impl Default for CheetahBuilder
Source§impl<'a> Extend<&'a str> for CheetahBuilder
impl<'a> Extend<&'a str> for CheetahBuilder
Source§fn extend<T: IntoIterator<Item = &'a str>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a str>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<char> for CheetahBuilder
impl Extend<char> for CheetahBuilder
Source§fn extend<T: IntoIterator<Item = char>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = char>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)