pub struct Builder(/* private fields */);
Expand description
This is a growable string builder.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn append<T: ToBytes>(&mut self, buf: T)
pub fn append<T: ToBytes>(&mut self, buf: T)
Add a type that can be viewed as a slice of bytes.
§Example
use string_builder::Builder;
let mut builder = Builder::default();
builder.append("some string");
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the current length in bytes of the underlying buffer.
§Example
use string_builder::Builder;
let mut builder = Builder::default();
builder.append("four");
assert_eq!(builder.len(), 4);
Sourcepub fn string(self) -> Result<String, FromUtf8Error>
pub fn string(self) -> Result<String, FromUtf8Error>
Return a String
of our buffer once we are done appending to it. This method consumes
the underlying buffer.
§Example
use string_builder::Builder;
let mut builder = Builder::default();
builder.append("i am building");
builder.append(' ');
builder.append("a string");
assert_eq!(builder.string().unwrap(), "i am building a string");
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more