diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-10-14 17:32:37 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-10-14 18:07:18 +0200 |
| commit | 5e41672a91536c1f740bbc1630a6908adff57329 (patch) | |
| tree | 2f481ab7a205154b11deaf4925aa5a0f693d7f23 /src/layout/mod.rs | |
| parent | 7c0899b5373cdc4f1083a0a8515856207c431423 (diff) | |
Refactor and refine PDF exporter ♻
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 14aa6417..abf140d6 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -76,6 +76,11 @@ impl MultiLayout { self.layouts.push(layout); } + /// The count of sublayouts. + pub fn count(&self) -> usize { + self.layouts.len() + } + /// Whether this layout contains any sublayouts. pub fn is_empty(&self) -> bool { self.layouts.is_empty() @@ -91,6 +96,16 @@ impl IntoIterator for MultiLayout { } } +impl<'a> IntoIterator for &'a MultiLayout { + type Item = &'a Layout; + type IntoIter = std::slice::Iter<'a, Layout>; + + fn into_iter(self) -> Self::IntoIter { + self.layouts.iter() + } +} + + /// The context for layouting. #[derive(Copy, Clone)] pub struct LayoutContext<'a, 'p> { |
