diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-23 14:36:40 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-23 14:36:40 +0100 |
| commit | 457ce954366f3a81989fee788c85a5b20a96ce96 (patch) | |
| tree | bb591fb025adcaaec424f9f52b39fb96af5ca17e /src/model/content.rs | |
| parent | a1d47695a2af5afa466c21ad812a1a8212780293 (diff) | |
More EcoVec usage
Frame unfortunately can't use it because splice is missing.
Diffstat (limited to 'src/model/content.rs')
| -rw-r--r-- | src/model/content.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/model/content.rs b/src/model/content.rs index fde0a5cd..b8047ffa 100644 --- a/src/model/content.rs +++ b/src/model/content.rs @@ -6,9 +6,8 @@ use std::ops::{Add, AddAssign}; use std::sync::Arc; use comemo::Tracked; -use ecow::EcoString; +use ecow::{EcoString, EcoVec}; use siphasher::sip128::{Hasher128, SipHasher}; -use thin_vec::ThinVec; use typst_macros::node; use super::{ @@ -25,7 +24,7 @@ use crate::World; pub struct Content { obj: Arc<dyn Bounds>, span: Option<Span>, - modifiers: ThinVec<Modifier>, + modifiers: EcoVec<Modifier>, } /// Modifiers that can be attached to content. @@ -68,9 +67,9 @@ impl Content { /// Attach a label to the content. pub fn labelled(mut self, label: Label) -> Self { - for modifier in &mut self.modifiers { - if let Modifier::Label(prev) = modifier { - *prev = label; + for (i, modifier) in self.modifiers.iter().enumerate() { + if matches!(modifier, Modifier::Label(_)) { + self.modifiers.make_mut()[i] = Modifier::Label(label); return self; } } @@ -408,7 +407,7 @@ pub trait Node: 'static + Capable { Content { obj: Arc::new(self), span: None, - modifiers: ThinVec::new(), + modifiers: EcoVec::new(), } } |
