mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-25 23:10:30 +00:00
oh, commit this
This commit is contained in:
parent
54f58cd726
commit
850a13e913
1 changed files with 33 additions and 0 deletions
33
src/helpers.rs
Normal file
33
src/helpers.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
use ansi_term::Color::{Green, Red, Yellow};
|
||||
use std::fmt::Display;
|
||||
|
||||
pub fn verify<T: PartialEq + Display>(left: T, right: T) {
|
||||
if left == right {
|
||||
println!("{} {} == {}", Green.bold().paint("PASS"), left, right);
|
||||
} else {
|
||||
println!(
|
||||
"{} You submitted {}, but that's not correct!",
|
||||
Red.bold().paint("FAIL"),
|
||||
left
|
||||
);
|
||||
println!(" Please correct your code to make this test pass!");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn verify_easy<T: PartialEq + Display>(left: T, right: T) {
|
||||
if left == right {
|
||||
println!("{} {} == {}", Green.bold().paint("PASS"), left, right);
|
||||
} else {
|
||||
println!(
|
||||
"{} You submitted {}, but that's not correct!",
|
||||
Red.bold().paint("FAIL"),
|
||||
left
|
||||
);
|
||||
println!(" Expected: {}", right);
|
||||
println!(" Please correct your code to make this test pass!");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn title(s: &str) {
|
||||
println!("{} {}", Yellow.bold().paint("RUN"), s);
|
||||
}
|
Loading…
Reference in a new issue