| Crates.io | ino_color |
| lib.rs | ino_color |
| version | 3.0.0 |
| created_at | 2025-02-05 11:37:56.500848+00 |
| updated_at | 2025-03-01 12:35:13.275763+00 |
| description | A output coloring crate with limited functionality, limit platform support and limited allocations. |
| homepage | |
| repository | https://github.com/MidAutumnMoon/InOri |
| max_upload_size | |
| id | 1543868 |
| size | 13,249 |
A output coloring crate with limited functionality, limit platform support and limited allocations. It's perfect for scratching tiny spot of itch.
// This's the trait that adds coloring methods.
use ino_color::InoColor;
// These two modules contain predefined colors and styles.
// As a personal preferrence, wildcard import is avoided,
// even though doing so makes the function call looks funnier.
use ino_color::fg;
use ino_color::style;
// The most basic usage
println!(
"{}", "Hello Fancy".fg::<fg::Yellow>()
);
// It's also chainable!
println!(
"{}", "Savoy blue".fg::<fg::Blue>().style::<style::Italic>()
);
// In fact, anything implements `std::fmt` traits can be colored.
println!( "{:?}", vec![123].fg::<fg::Green>() );
println!( "{:X}", 123.fg::<fg::Green>() );
Linux only.
Can't set background color (yet?).
Only supports 16 named (4-bit) colors.
All color and style selections are done in type level, meaning coloring can't be changed at runtime.
owo-colors for inventing this API, explained next section.owo-colorsThis implementation has similar interfaces with owo-colors, namely the using of generic to select color and styles.
owo-color is good and slime, however its interface is bloated with "convenient" color methods,
90% out of which will never be called anyway. More over, the caller needs to jump some hoops and be explicit
about whether to enable colors (the if_supports_color method), which is both good and bad.
ino_color removes the runtime color selection support, in gain it has a even slimer API. And as stated in Pros,
it follows the ANSI color standard by default, although the various checks do introduce amounts of costs, so it's
recommended to cache the colored result, or use *_always APIs to skip the check.