lazy_concat 0.1.3

Lazy concatenation for Strings and Vecs
Documentation
  • Coverage
  • 71.43%
    20 out of 28 items documented4 out of 19 items with examples
  • Size
  • Source code size: 28.51 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • peterjoel/lazy_concat
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • peterjoel

lazy_concat

Lazy concatenation to String or Vec, supporting iteration and slices.

Documentation

Automatic generated documentation can be found here.

Usage

[dependencies]
lazy_concat = "0.1.1"
extern crate lazy_concat;
use lazy_concat::LazyConcat;

let mut lazy_string = LazyConcat::new(String::new())
    // No allocations happen here
    .and_concat("Hello")
    .and_concat(" ")
    .and_concat("there!");

// Iteration works without any new allocation
for byte in lazy_string.bytes() {
    println!("byte = {:?}", byte);
}
// This extra block scope is not required with #[feature(nll)] (non-linear lifetimes).
{
    // Before taking a slice, make sure the required range is already concatenated
    if lazy_string.slice_needs_normalization(1..4) {
        lazy_string.normalize_to_len(4);
    }
    let slice = lazy_string.get_slice(1..4);
    assert_eq!("ell", slice);
}
// Finally allocate and concatenate the remainder of the string
let string: String = lazy_string.done();
assert_eq!("Hello there!", string);