pub struct Fragments { /* private fields */ }Expand description
The fragment store: every finalized fragment’s parts laid end to end in ONE arena, addressed by a per-fragment span.
Fragments are append-only and immutable once finalized (they exist so a
choice’s text or a computed substring can be re-rendered later, in
another locale), so nothing ever needs to grow or drop one in place —
which is what makes a shared arena safe. Before this, each fragment
owned its own Vec<OutputPart>, and end_fragment built two of them
(drain().collect() then skip(1).collect()) per capture: 182K of
hanoi-10’s ~1M heap blocks were exactly those vectors. Now a capture
moves its parts once, into the arena’s spare capacity.
Indices are unchanged by the layout: fragment i is the i-th span,
exactly as it was the i-th Vec — Value::FragmentRef(i) and the
persisted .brkt numbering mean the same thing they always did.
Fragment remains the materialized, owning form the codec and tests
speak; Self::to_vec / From<Vec<Fragment>> convert.
Implementations§
Source§impl Fragments
impl Fragments
Sourcepub fn parts(&self, idx: u32) -> Option<&[OutputPart]>
pub fn parts(&self, idx: u32) -> Option<&[OutputPart]>
The parts of fragment idx, if it exists.
The tags of fragment idx, if it exists.
Sourcepub fn get(&self, idx: u32) -> Option<FragmentRef<'_>>
pub fn get(&self, idx: u32) -> Option<FragmentRef<'_>>
Fragment idx as a borrowed view, if it exists.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = FragmentRef<'_>> + '_
pub fn iter(&self) -> impl ExactSizeIterator<Item = FragmentRef<'_>> + '_
Every fragment, in index order.