Skip to main content

wrap_prefixed

Function wrap_prefixed 

Source
pub fn wrap_prefixed(text: &str, prefix: &str, width: usize) -> String
Expand description

Word-wrap text to width columns and prefix every line with prefix (e.g. "> " for a Markdown blockquote, or the leading indent of a wrapped list item). Collapses runs of whitespace and never splits a word, so a single token longer than the width — a URL, typically — overflows rather than being broken. Such a token also stays on the line it started on: breaking before a word that won’t fit on a fresh line either would only orphan whatever label introduces it (LINK:, Minutes:) while still overflowing.