owo colors
1.0.0
零分配NO_STD兼容零成本的方式,以增加锈蚀终端的颜色,以使人们变得偏离。
支持:
NO_COLOR
/ FORCE_COLOR
环境变量推出set_override
编程地填充Owo-colors也是彩色的倒入替代品,允许彩色在NO_STD环境中工作。不需要分配或依赖项,因为嵌入式系统应该太UWU了。
添加到您的货物.toml:
owo-colors = " 3 "
use owo_colors :: OwoColorize ;
fn main ( ) {
// Foreground colors
println ! ( "My number is {:#x}!" , 10 .green ( ) ) ;
// Background colors
println ! ( "My number is not {}!" , 4 .on_red ( ) ) ;
}
use owo_colors :: OwoColorize ;
use owo_colors :: colors :: * ;
fn main ( ) {
// Generically color
println ! ( "My number might be {}!" , 4 .fg::< Black > ( ) .bg::< Yellow > ( ) ) ;
}
use owo_colors :: OwoColorize ;
println ! ( "{}" , "strikethrough" .strikethrough ( ) ) ;
use owo_colors :: { OwoColorize , Stream :: Stdout } ;
println ! (
"{}" ,
"colored blue if a supported terminal"
.if_supports_color ( Stdout , |text| text.bright_blue ( ) )
) ;
支持NO_COLOR
/ FORCE_COLOR
环境变量,检查它是否是TTY,检查它是否在CI中运行(因此很可能支持颜色),并检查使用了哪些终端。 (注意:需要supports-colors
功能)