memea

Function bar

Source
pub fn bar(header: Option<&str>, ch: char) -> String
Expand description

Creates a formatted horizontal bar for terminal output.

This function generates a horizontal separator bar using the specified character, optionally with a centered header text. The bar width adapts to the terminal size or defaults to 80 characters.

§Arguments

  • header - Optional text to center in the bar
  • ch - Character to use for the bar (e.g., ‘-’, ‘=’, ‘*’)

§Returns

Formatted string containing the bar with optional header

§Examples

use memea::bar;

let simple_bar = bar(None, '-');
let header_bar = bar(Some("Results"), '=');
println!("{}", header_bar);