diff options
| author | bors <bors@rust-lang.org> | 2020-02-26 11:48:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-26 11:48:01 +0000 |
| commit | 7e8530b21ff355c9b52e07eb3ba25278746a6932 (patch) | |
| tree | f100795973f84cf46fb240adcdaaaa2cd76a1aaf /src/ui.rs | |
| parent | 98358597a981aeeb039d756934d1ff91a2d8d7dc (diff) | |
| parent | 43dc31193afddc15c78d2ceb57f7c68da90e8a46 (diff) | |
Auto merge of #271 - jrvidal:refactor, r=fmoko
refactor: exercise evaluation
After working a bit on #270, I realized that it'd be useful to first perform a minor refactor of exercise evaluation.
* Now we have standard methods to compile + execute that return `Result`s.
* Success/failure messages are standardized.
Diffstat (limited to 'src/ui.rs')
| -rw-r--r-- | src/ui.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ui.rs b/src/ui.rs new file mode 100644 index 0000000..38cbaa4 --- /dev/null +++ b/src/ui.rs @@ -0,0 +1,23 @@ +macro_rules! warn { + ($fmt:literal, $ex:expr) => {{ + use console::{style, Emoji}; + let formatstr = format!($fmt, $ex); + println!( + "{} {}", + style(Emoji("⚠️ ", "!")).red(), + style(formatstr).red() + ); + }}; +} + +macro_rules! success { + ($fmt:literal, $ex:expr) => {{ + use console::{style, Emoji}; + let formatstr = format!($fmt, $ex); + println!( + "{} {}", + style(Emoji("✅", "✓")).green(), + style(formatstr).green() + ); + }}; +} |
