Skip to main content

build_excerpt

Function build_excerpt 

Source
pub fn build_excerpt(raw: &str) -> String
Expand description

Build a head + tail excerpt of raw suitable for embedding in an error message.

Pure head when raw fits in the combined budget; otherwise emits <head>… (N bytes elided) …<tail> with a real “bytes elided” count so the operator knows how much was dropped.

Always slices on char boundaries — a raw completion can contain arbitrary UTF-8 (model emitted prose, emoji in user-provided inputs echoed back, etc.), and slicing through a multi-byte code point would panic.