[−][src]Trait abin::BinBuilder
Trait used to build a binary efficiently (with just one allocation & no re-allocation or even without allocation).
use abin::{NewBin, BinSegment, Bin, AnyBin, BinBuilder}; let mut builder = NewBin::builder(); builder.push(BinSegment::Static("Hello, ".as_bytes())); builder.push(BinSegment::Static("World!".as_bytes())); let bin : Bin = builder.build(); assert_eq!("Hello, World!".as_bytes(), bin.as_slice());
Associated Types
Loading content...Required methods
fn push(&mut self, segment: impl Into<BinSegment<'a, Self::T>>)
fn build(&mut self) -> Self::T
Builds the binary.
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.