summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorRyan Pitasky <111201305+rpitasky@users.noreply.github.com>2023-03-24 04:15:24 -0400
committerGitHub <noreply@github.com>2023-03-24 09:15:24 +0100
commit8b1852cffb9abd128da29e87598d5f37d39f4f4b (patch)
tree5488c9417b78bbffce524eafd311841f2cfc08b1 /library
parent2f8802a412fb7ce888c34823a5f39f083909a9cc (diff)
Replace infinite repeat layout panic with error (#235)
When a page has auto width and there were no other constraints on the repetition width, this would previously panic. Now, there is an explicit check with a new error and test case.
Diffstat (limited to 'library')
-rw-r--r--library/src/layout/repeat.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/src/layout/repeat.rs b/library/src/layout/repeat.rs
index a44bd075..4a05500e 100644
--- a/library/src/layout/repeat.rs
+++ b/library/src/layout/repeat.rs
@@ -9,6 +9,9 @@ use super::AlignElem;
/// Space may be inserted between the instances of the body parameter, so be
/// sure to include negative space if you need the instances to overlap.
///
+/// Errors if there no bounds on the available space, as it would create
+/// infinite content.
+///
/// ## Example
/// ```example
/// Sign on the dotted line:
@@ -48,6 +51,11 @@ impl Layout for RepeatElem {
let apart = remaining / (count - 1.0);
let size = Size::new(regions.size.x, piece.height());
+
+ if !size.is_finite() {
+ bail!(self.span(), "repeat with no size restrictions");
+ }
+
let mut frame = Frame::new(size);
if piece.has_baseline() {
frame.set_baseline(piece.baseline());