Crate lazy_concat[][src]

Lazy concatenation of Strings, Vecs and any other concatenable data structures.

A LazyConcat owns a base structure and keeps track of fragments which can be either borrowed or owned. The fragments are never actually concatenated until the structure is normalized with normalize() or partially with normalize_to_len().

When borrowing a slice, it is possible to normalize only the minimum number of fragments required for the slice. Various iterators over String or Vec are supported without the need to normalize first.

Examples

let mut lz = LazyConcat::new(Vec::new())
    // Concatenating owned values
    .concat(vec![0, 1, 2, 3, 4])
    // And borrowed values
    .concat(&[5, 6, 7, 8][..])
    .concat(&[9, 10][..]);
// This is possible without the above slice being concatenated
for i in lz.iter() {
    println!("i = {}", i);
}
// Actually concatenate enough values so that up to 6 elements can be sliced
lz.normalize_to_len(6);
let slice: &[i32] = lz.get_slice(2..6);
assert_eq!(&[2, 3, 4, 5], slice);

Structs

LazyConcat

Traits

Concat

Concatenation onto an owned value.

Length

A trait for types whose values have a length, in bytes.

Sliceable