Repository navigation
[BREAKING] v0.18.0 - Comp-time Unification, Part 1
Farben is constantly updating. Here are the new changes to v0.18.0: Comp-time Unification, Part 1.
Note
This implementation was suggested by redditor u/manpacket on the r/Rust subreddit. The post can be seen here. Thank you manpacket!
core0.13.4 / macros0.6.0 / frb0.18.0 / build0.1.4 — 2026-04-20
Compile-time Runtime Detection
Important
This update introduces breaking changes to compile users. See the Breaking section down below and the migration guide.
Added
strip_markup(input: &str) -> Stringinfarben-core::strip: strips farben
markup tags from a string, returning plain text. Re-exported fromfarbenas
farben::strip_markup.markup_strip!macro that behaves the same asansi_strip!but usesstrip_markuprender_forced(tokens: Vec<Token>) -> Stringinfarben-core::parser: renders
tokens to ANSI unconditionally, bypassingcolor_enabled(). Used internally by
thecolor!andcolorb!proc macros to ensure the styled variant is always
baked in regardless of the build environment.FarbenStrinfarben: a compile-time string pair holding both a styled
(&'static str) and plain (&'static str) variant, resolved at the user's
runtime viaFarbenStr::resolve()andDisplay.color_enabled()re-exported fromfarben: previously only accessible via
farben_core.- Doc comments of
init_styles()offarben-build.
Changed
color!andcolorb!now emit aFarbenStrinstead of a bare&'static str,
baking both ANSI and plain variants into the binary and deferring the
NO_COLOR/FORCE_COLOR/TTY decision to the end user's runtime.render()now delegates its ANSI rendering path torender_forced().
Breaking
color!andcolorb!no longer return&'static str. Code storing the result
as&strmust call.resolve()explicitly. Usage insidecprintln!,cprint!,
cwrite!, and all other print/write macros is unaffected as they go through
Display.
Migrating (compile users)
- If you only use
cprintln!,cprint!, etc, then you are safe. No changes needed. - But when you directly use
color!and/orcolorb!, then follow the steps:
color!andcolorb!no longer return&'static str.- Change calls that use
color!,colorb!as an expression of&'static strto use.resolve() - Example:
use farben::prelude::*;
// change this
let previous: &str = color!("[bold red]Hi");
// to be
let new: &str = color!("[bold red]Hi").resolve();- Why? See changes above. The
color!,colorb!procedural macros now return a specialFarbenStrinstead of a&str.
Make great things with Farben.
Cheers, RazkarStudio.