| Crates.io | ansic |
| lib.rs | ansic |
| version | 0.1.7 |
| created_at | 2025-06-10 09:17:35.67493+00 |
| updated_at | 2025-07-02 08:16:57.570064+00 |
| description | Ansic is a crate which does ansi parsing in a dynamic DSL and at compile time for efficient and zero cost ansi styling. |
| homepage | https://github.com/zeonzip/ansic |
| repository | https://github.com/zeonzip/ansic |
| max_upload_size | |
| id | 1706875 |
| size | 20,799 |
The most efficient and easy ansi styling crate ever!
Ansic is a crate which adds the ansi! proc macro, which allows for easy, simple and zero cost styling which happens at compiletime, in addition to other ansi utilities. (with default and 100% support for #[no_std])
To make a red foreground, bold and underline ansi
ansi!(red bold underline)
All color arguments can take these arguments:
You can chain them like this if we want a red background:
ansi!(bg.red bold underline)
Or if you want a red bright background you can do this:
ansi!(bg.br.red bold underline)
In addition we can add a foreground color now that we have a background one. Let's add green!
ansi!(bg.br.red green bold underline)
Idiomatic ansic syntax is also storing styles in constants and using them to style in a much less verbose way:
const ERROR: &str = ansi!(br.red bold underline italic);
const R: &str = ansi!(reset);
fn main() {
println!("{ERROR}[ERROR]: Hello, world!{R}");
}
Ansic also supports full RGB styles with the color syntax "rgb(r, g, b)".
Ansic has alot more styles which you can find on our docs.rs page: Ansic on Docs.rs; Ansic also has util macros and functions for more convenient use (listed under Comparisons)
| Feature | Ansic ✅ | owo-colors ⚠️/✅ | ansi_term ❌/⚠️ |
|---|---|---|---|
| FULLY Compile Time Generation | Yes ✅ | No ❌ | No ❌ |
| Zero Runtime Cost | Yes ✅ | No ❌ | No ❌ |
| Minimal Binary Size | Zero extra ✅ | Very Low ⚠️ | Medium ⚠️ |
| Supports RGB Styles | Yes ✅ | Yes ✅ | No ❌ |
| No-Std support | Yes ✅ | Yes ✅ | Yes ✅ |
| Reusable Style Constants | Yes ✅ | Awkward ⚠️ | Partial ⚠️ |
| Simple Macro DSL | Yes ✅ | No ❌ | No ❌ |
| ANSI Reset Handling | Via styled! from utils ⚠️ |
Automatic ✅ | Manual ⚠️ |
| Text Injection | Yes ✅ | Yes ✅ | Yes ✅ |
| Extensibility / Custom DSL | Yes ✅ | No ❌ | No ❌ |
| Windows Compatibility | Can be enabled ✅ (via vt_mode!()) | Yes ✅ | Yes ✅ |
| Well-maintained | New, active 🚧 | Yes ✅ | Mostly deprecated ⚠️ |
There are tons of other ansi styling crates out there, so why ansic?
Ansic is for people who need a ANSI styling crate, which more efficient, easier for maintainability or #[no_std].
Ansic solves this with a simple and very readable reuseability pattern, proc macro DSL, and being fully compile time letting you live without the stress of bigger binary sizes.