1
0
Fork 0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-05-25 05:26:12 +02:00
rustlings/src/helpers.rs
2018-05-22 22:28:13 +02:00

34 lines
993 B
Rust

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