summaryrefslogtreecommitdiff
path: root/crates/typst-layout/src/math/lr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-layout/src/math/lr.rs')
-rw-r--r--crates/typst-layout/src/math/lr.rs11
1 files changed, 2 insertions, 9 deletions
diff --git a/crates/typst-layout/src/math/lr.rs b/crates/typst-layout/src/math/lr.rs
index 19176ee8..bf823541 100644
--- a/crates/typst-layout/src/math/lr.rs
+++ b/crates/typst-layout/src/math/lr.rs
@@ -2,6 +2,7 @@ use typst_library::diag::SourceResult;
use typst_library::foundations::{Packed, StyleChain};
use typst_library::layout::{Abs, Axis, Rel};
use typst_library::math::{EquationElem, LrElem, MidElem};
+use typst_utils::SliceExt;
use unicode_math_class::MathClass;
use super::{stretch_fragment, MathContext, MathFragment, DELIM_SHORT_FALL};
@@ -29,15 +30,7 @@ pub fn layout_lr(
let mut fragments = ctx.layout_into_fragments(body, styles)?;
// Ignore leading and trailing ignorant fragments.
- let start_idx = fragments
- .iter()
- .position(|f| !f.is_ignorant())
- .unwrap_or(fragments.len());
- let end_idx = fragments
- .iter()
- .skip(start_idx)
- .rposition(|f| !f.is_ignorant())
- .map_or(start_idx, |i| start_idx + i + 1);
+ let (start_idx, end_idx) = fragments.split_prefix_suffix(|f| f.is_ignorant());
let inner_fragments = &mut fragments[start_idx..end_idx];
let axis = scaled!(ctx, styles, axis_height);