Crate lazy_concat[−][src]
Lazy concatenation of String
s, Vec
s 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 fully normalized with normalize
or
partially normalized 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 .and_concat(vec![0, 1, 2, 3, 4]) // And borrowed values .and_concat(&[5, 6, 7, 8][..]) .and_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
ConcatOnly |
Provides a mutable view onto a |
LazyConcat |
Traits
Concat |
Concatenation onto an owned value. |
Length |
A trait for types whose values have a length, in bytes. |
Sliceable |