Skip to main content

Module elision

Module elision 

Source
Expand description

What a cut says, and where a cut may land.

Four places in this crate remove bytes from a text: the frozen prefix, the result pipeline, the compactor and the sieve. They share two facts, and both live here.

One sentence for “bytes were taken away”. A reader — a person or a model — meets the same wording wherever it happens, and replay::rebuild_prefix reproduces a recorded prefix byte for byte because the sentence has one author. The marker is English and ASCII: it faces the model’s English window.

One rule for where a cut lands, and it answers with a value. A byte budget and a cut in the middle of a character produce bytes nothing downstream can read, so every cut moves to a character boundary, and the answer is a Boundary: the bytes on each side of the cut, each holding whole characters. An offset and the text it indexes are two facts that can disagree, and str::get answers the disagreement with None, which a caller then reads as “nothing was kept here”; the two sides cannot disagree with the text they came from.

The count a marker carries is source bytes removed, and the marker itself is never one of them: add dropped to the length of the text without its marker and the input length comes back, at any offset a caller computed.

Structs§

Cut
One shortened text, with the account of what it no longer carries.

Enums§

Elided
Where the bytes that are gone used to be.

Functions§

boundary_after
The smallest character boundary at or after at.
boundary_before
The largest character boundary at or before at.
gap_marker
The same sentence on a line of its own, for bytes removed from inside a text rather than from one of its ends.
gap_marker_room
marker_room for a marker on a line of its own.
marker
The sentence that stands where the removed bytes were.
marker_room
How many bytes to reserve for a marker before the count is known.
splice
The cut a caller assembles: the bytes before front, the marker, and the bytes from back on.