macro_rules! text {
() => { ... };
($($rest:tt)*) => { ... };
}
Expand description
Macro to declare a list of text segments. A segment can be written as
"text"
(a string literal){expr}
(an expression that evaluates to a string slice)
Each segment can be preceded by one of
c:
, wherec
is aColor
variant; the segment is printed in color if supported, otherwise it is wrapped in backticksc!
, wherec
is aColor
variant; the segment is printed in color if supported, otherwise no formatting is applied
Each color can be abbreviated with its first letter (cyan ➔ c, green ➔ g, magenta ➔ m, red ➔ r, yellow ➔ y); use an uppercase letter to make it bold (bold cyan ➔ C, etc.)
Segments are not separated with commas, for example:
// "warning" is yellow and bold, "world" is cyan, or wrapped in backticks
let _segments = text!(Y!"warning" ": hello" c:"world");
// the value of an build-time environment variable is printed in magenta
let _segments = text!("version is " m!{env!("CARGO_PKG_VERSION")});