Function terminal_cli::format_in_columns [−] [src]

pub fn format_in_columns(strings: &[&str], width: u16, min_spacing: u16, new_line: &str) -> String

Formats the strings in autocomplete-style column notation. Adds spaces in between. Preserves the ordering. Last line will contain the newline sequence.

Example

#![feature(convert)]
let s = vec!["A1", "A2", "A3", "B1", "B2", "C1", "C2"];
let f = format_in_columns(s.as_slice(), 26, 10, "\r\n");
println!("{}", f);

Example output

A1          B1          C2
A2          B2
A3          C1