diff options
| author | Martin <mhaug@live.de> | 2021-06-18 13:00:36 +0200 |
|---|---|---|
| committer | Martin <mhaug@live.de> | 2021-06-18 13:00:36 +0200 |
| commit | 7db78d83bedf62adea0d715c9a2a179ce23a1a48 (patch) | |
| tree | 71c1db7fe3fae60390e46e18148c5b252b811c48 /src/layout/incremental.rs | |
| parent | 2a30c20f0e2c3b51d3b2746a60e15008f1aa2619 (diff) | |
Levels
Diffstat (limited to 'src/layout/incremental.rs')
| -rw-r--r-- | src/layout/incremental.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/layout/incremental.rs b/src/layout/incremental.rs index 427df079..7857f33c 100644 --- a/src/layout/incremental.rs +++ b/src/layout/incremental.rs @@ -20,6 +20,19 @@ impl LayoutCache { pub fn clear(&mut self) { self.frames.clear(); } + + /// Retains all elements for which the closure on the level returns `true`. + pub fn retain<F>(&mut self, mut f: F) + where + F: FnMut(usize) -> bool, + { + self.frames.retain(|_, b| f(b.level)); + } + + /// Amount of items in the cache. + pub fn len(&self) -> usize { + self.frames.len() + } } #[derive(Debug, Clone)] @@ -27,6 +40,8 @@ impl LayoutCache { pub struct FramesEntry { /// The cached frames for a node. pub frames: Vec<Constrained<Frame>>, + /// How nested the frame was in the context is was originally appearing in. + pub level: usize, } impl FramesEntry { |
