Skip to main content

wrap_text

Function wrap_text 

Source
pub fn wrap_text(text: &str, width: usize) -> Vec<String>
Expand description

Wrap text at specified width

ยงExamples

use reinhardt_utils::utils_core::encoding::wrap_text;

let text = "This is a long line that needs to be wrapped";
let wrapped = wrap_text(text, 20);
assert!(wrapped.len() > 1);
assert!(wrapped.iter().all(|line| line.chars().count() <= 25));