Skip to main content

shorten

Function shorten 

Source
pub fn shorten(text: &str, strategy: Strategy, budget: ByteLen) -> Cut
Expand description

Carries out a shortening the caller has already decided on.

The answer carries the text, the source bytes it lost and which end lost them, so no caller has to recover the loss by subtracting two lengths — a subtraction that counted the inserted marker as surviving text and under-reported the loss by its width.

Taking the strategy rather than deciding it again is what keeps this module out of the business of what leaves the window: a caller holding Shrink::MustOffload has nothing to call here.