From 69ff4a8b2554f4113b759a7935cb611aa13ab9ad Mon Sep 17 00:00:00 2001 From: olivia Date: Tue, 22 May 2018 22:23:22 +0200 Subject: replace macros with more general methods --- src/main.rs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 68b8c9e..133bdf4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,11 +2,41 @@ extern crate quicli; extern crate ansi_term; -use ansi_term::Color::Yellow; +use ansi_term::Color::{Green, Red, Yellow}; use quicli::prelude::*; +use std::fmt::Display; + +pub fn verify(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(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); +} -#[macro_use] -mod macros; mod about_variables; #[derive(Debug, StructOpt)] -- cgit v1.2.3