pub fn chunks(s: &str, chunk_size: usize) -> Vec<String>
Expand description

Returns an Vec over chunk_size elements of string, starting at the beginning of the slice. It uses chars but not bytes!

The chunks are vectors and do not overlap. If chunk_size does not divide the length of the slice, then the last chunk will not have length chunk_size.

Panics

Panics if chunk_size is 0.

Examples

use owo_colors::{OwoColorize, colors::*};
let colored_text = format!("{} {} {}", "A".fg::<Black>(), "Colored".fg::<Red>(), "Text".fg::<Blue>()).bg::<Yellow>().to_string();
let chunks = ansi_cut::chunks(&colored_text, 3);
for chunk in &chunks {
    println!("{}", chunk);
}