jam1garner / owo-colors

A zero-allocation no_std-compatible zero-cost way to add color to your Rust terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature request] Support feature flag for compile-time library deactivation

matrach opened this issue · comments

Hi!

Thanks for such a great library! It is really convenient to use in our no-alloc project.

Would it be possible to add a no-color feature flag similarly to colored, that would make the library compile to a no-op and completely disappear in the resulting binary after llvm optimizations? In very constrained environments it would save a lot of Flash memory among others. With this option, the same codebase could be shared between different scales of available resources (like tens of KB Flash to MBs of Flash).

The other benefit is that users of the binary could use the simple interface without having to place if_support_colors everywhere, and then compile-time determine whether the logs should be colorful (e.g. in debug builds) or plain-text (in release).

I think it would be possible, I'll try to find time in the next few weeks to figure out an implementation

commented

Generally features should be additive only otherwise this might results in unexpected behavior in large codebases

https://github.com/rust-lang/cargo/blob/master/src/doc/src/reference/features.md#feature-unification