diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-24 18:47:43 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-24 19:15:11 +0100 |
| commit | 49c0bac44dda8be643480df2c4e68623eeec91bd (patch) | |
| tree | 6f697031013e4259bdfefc7977edc8d9d683e823 /src/eval/styles.rs | |
| parent | 90132b0d658f1b2a5df75eb458150e6782b2c30c (diff) | |
First-line indents
Co-Authored-By: Martin Haug <mhaug@live.de>
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 |
