A Rust library for formatting text with ANSI terminal colors and styles like bold, underline, and background colors.
rust-ansi-term is a Rust library for adding colors and text styles (like bold, underline, and background colors) to terminal output using ANSI escape codes. It solves the problem of manually constructing and managing ANSI sequences by providing a type-safe, efficient API that works across platforms, including Windows 10 with enabled ANSI support.
Rust developers building command-line tools, terminal applications, or logging systems that require colored or styled text output in ANSI-compatible terminals.
Developers choose rust-ansi-term for its zero-allocation design, type safety, and optimization of consecutive styled strings, which reduces escape sequence overhead and improves performance compared to manual string concatenation.
Rust library for ANSI terminal colours and styles (bold, underline)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses ANSIString and Style types to enforce correctness at compile time, preventing malformed ANSI escape sequences and reducing bugs.
Optimizes ANSI code output with ANSIStrings to minimize terminal overhead when combining styled strings, as demonstrated in the README's binary number example.
Includes 256-color and 24-bit RGB options beyond basic ANSI colors, allowing for precise color matching in modern terminals.
Supports formatting [u8] byte strings for non-UTF-8 text, useful in applications handling unknown encodings, though it requires manual write operations.
Requires explicit call to enable_ansi_support() on Windows 10, adding runtime complexity and potential failure points if the terminal lacks support.
Lacks pre-defined styles or themes, forcing developers to build all styling from scratch, which can be verbose for common patterns like error messages.
Does not automatically detect terminal capabilities or provide fallbacks for unsupported features, leaving color compatibility checks entirely to the user.