mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-30 17:26:28 +00:00
41 lines
1 KiB
Rust
41 lines
1 KiB
Rust
macro_rules! warn {
|
|
($fmt:literal, $ex:expr) => {{
|
|
use std::env;
|
|
use console::{style, Emoji};
|
|
let formatstr = format!($fmt, $ex);
|
|
if env::var("NO_EMOJI").is_ok() {
|
|
println!(
|
|
"{} {}",
|
|
style("!").red(),
|
|
style(formatstr).red()
|
|
);
|
|
} else {
|
|
println!(
|
|
"{} {}",
|
|
style(Emoji("⚠️ ", "!")).red(),
|
|
style(formatstr).red()
|
|
);
|
|
}
|
|
}};
|
|
}
|
|
|
|
macro_rules! success {
|
|
($fmt:literal, $ex:expr) => {{
|
|
use std::env;
|
|
use console::{style, Emoji};
|
|
let formatstr = format!($fmt, $ex);
|
|
if env::var("NO_EMOJI").is_ok() {
|
|
println!(
|
|
"{} {}",
|
|
style("✓").green(),
|
|
style(formatstr).green()
|
|
);
|
|
} else {
|
|
println!(
|
|
"{} {}",
|
|
style(Emoji("✅", "✓")).green(),
|
|
style(formatstr).green()
|
|
);
|
|
}
|
|
}};
|
|
}
|