[−][src]Trait abin::StrBuilder
Trait used to build a string efficiently (with just one allocation & no re-allocation or even without allocation).
use abin::{NewStr, StrSegment, Str, StrBuilder}; let mut builder = NewStr::builder(); builder.push(StrSegment::Static("Hello, ")); builder.push(StrSegment::Static("World!")); let string : Str = builder.build(); assert_eq!("Hello, World!", string.as_str());
Associated Types
Loading content...Required methods
fn push(&mut self, segment: impl Into<StrSegment<'a, Self::T>>)
fn build(&mut self) -> AnyStr<Self::T>
Builds the string.
Note: After calling this method, the builder will be empty again and can be re-used. We
use &mut self
here instead of self
to make sure the builder is not copied (it's large).
I'm not sure how well rust would optimize self
here.