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

34 lines
938 B
Rust
Raw Normal View History

macro_rules! warn {
($fmt:literal, $ex:expr) => {{
use console::{style, Emoji};
2021-04-18 08:40:47 -05:00
use std::env;
let formatstr = format!($fmt, $ex);
if env::var("NO_EMOJI").is_ok() {
2021-04-18 08:40:47 -05:00
println!("{} {}", style("!").red(), style(formatstr).red());
} else {
println!(
"{} {}",
style(Emoji("⚠️ ", "!")).red(),
style(formatstr).red()
);
}
}};
}
macro_rules! success {
($fmt:literal, $ex:expr) => {{
use console::{style, Emoji};
2021-04-18 08:40:47 -05:00
use std::env;
let formatstr = format!($fmt, $ex);
if env::var("NO_EMOJI").is_ok() {
2021-04-18 08:40:47 -05:00
println!("{} {}", style("").green(), style(formatstr).green());
} else {
println!(
"{} {}",
style(Emoji("", "")).green(),
style(formatstr).green()
);
}
}};
}