Function display_utils::unicode_block_bar[][src]

pub fn unicode_block_bar(max_length: usize, proportion: f32) -> UnicodeBlockBar

Print a loading-style bar using Unicode block characters.

The bar is very high-resolution: 8 states can be represented per character.

Accepts the total length of the bar and a float from 0.0 to 1.0 as the filled proportion.

Prints exactly max_length chars (not bytes!), right-padded with spaces.

assert_eq!(unicode_block_bar(13, 0.0).to_string(), "             ");
assert_eq!(unicode_block_bar(13, 0.1).to_string(), "█▎           ");
assert_eq!(unicode_block_bar(13, 0.2).to_string(), "██▌          ");
assert_eq!(unicode_block_bar(13, 0.3).to_string(), "███▉         ");
assert_eq!(unicode_block_bar(13, 0.4).to_string(), "█████▏       ");
assert_eq!(unicode_block_bar(13, 0.5).to_string(), "██████▌      ");
assert_eq!(unicode_block_bar(13, 0.6).to_string(), "███████▊     ");
assert_eq!(unicode_block_bar(13, 0.7).to_string(), "█████████    ");
assert_eq!(unicode_block_bar(13, 0.8).to_string(), "██████████▍  ");
assert_eq!(unicode_block_bar(13, 0.9).to_string(), "███████████▋ ");
assert_eq!(unicode_block_bar(13, 1.0).to_string(), "█████████████");