Skip to main content

center

Function center 

Source
pub fn center(line: &str, width: usize) -> String
Expand description

Centers line in width columns.

Like Rich, the extra column of an odd margin goes to the right. The result is padded on both sides, so it is exactly width columns wide whenever line is narrower.

use shellgame::ui::text::center;

assert_eq!(center("ab", 7), "  ab   ");