This repository has been archived on 2023-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
rustlings-exercises-completed/src/ui.rs

42 lines
1.0 KiB
Rust
Raw Normal View History

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()
);
}
}};
}