diff options
Diffstat (limited to 'src/eval/styles.rs')
| -rw-r--r-- | src/eval/styles.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/eval/styles.rs b/src/eval/styles.rs index bd1f808f..8e7bd4b6 100644 --- a/src/eval/styles.rs +++ b/src/eval/styles.rs @@ -547,6 +547,17 @@ impl<T> StyleVec<T> { .flat_map(|(map, count)| std::iter::repeat(map).take(*count)); self.items().zip(styles) } + + /// Insert an element in the front. The element will share the style of the + /// current first element. + /// + /// This method has no effect if the vector is empty. + pub fn push_front(&mut self, item: T) { + if !self.maps.is_empty() { + self.items.insert(0, item); + self.maps[0].1 += 1; + } + } } impl<T> Default for StyleVec<T> { @@ -601,6 +612,11 @@ impl<'a, T> StyleVecBuilder<'a, T> { Some((item, chain)) } + /// Iterate over the contained items. + pub fn items(&self) -> std::slice::Iter<'_, T> { + self.items.iter() + } + /// Finish building, returning a pair of two things: /// - a style vector of items with the non-shared styles /// - a shared prefix chain of styles that apply to all items |
