From 4eca18050f21b3bc69477118845903ec61283d4f Mon Sep 17 00:00:00 2001 From: olivia Date: Tue, 22 May 2018 22:26:09 +0200 Subject: [PATCH] put it in a separate file --- src/about_variables.rs | 3 +-- src/macros.rs | 37 ------------------------------------- src/main.rs | 35 ++--------------------------------- 3 files changed, 3 insertions(+), 72 deletions(-) delete mode 100644 src/macros.rs diff --git a/src/about_variables.rs b/src/about_variables.rs index b4ebda0..1587dc0 100644 --- a/src/about_variables.rs +++ b/src/about_variables.rs @@ -1,5 +1,4 @@ -use title; -use verify; +use helpers::*; // Variables in Rust are defined using the "let" keyword. Like this: diff --git a/src/macros.rs b/src/macros.rs deleted file mode 100644 index 22c8783..0000000 --- a/src/macros.rs +++ /dev/null @@ -1,37 +0,0 @@ -#[macro_export] -macro_rules! title { - ($str:expr) => { - println!("{} {}", ansi_term::Color::Yellow.bold().paint("RUN"), $str); - } -} - -#[macro_export] -macro_rules! verify { - ($left:expr, $right:expr) => { - use ansi_term::Color::{Green, Red}; - - if $left == $right { - println!("{} {} == {}", Green.bold().paint("PASS"), $left, $right); - } else { - print!("{}", Red.bold().paint("FAIL")); - println!(" You submitted {}, but that's not correct!", $left); - println!(" Please correct your code to make this test pass!"); - } - }; -} - -#[macro_export] -macro_rules! verify_easy { - ($str:expr, $left:expr, $right:expr) => { - use ansi_term::Color::{Green, Red}; - - if $left == $right { - println!("{} {}", Green.bold().paint("PASS"), $str); - } else { - println!("{} {}", Red.bold().paint("FAIL"), $str); - println!("\tExpected: {}", $right); - println!("\tGot: {}", $left); - println!("\tPlease correct your code to make this test pass!"); - } - }; -} diff --git a/src/main.rs b/src/main.rs index 133bdf4..02f0227 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,41 +2,10 @@ extern crate quicli; extern crate ansi_term; -use ansi_term::Color::{Green, Red, Yellow}; +use ansi_term::Color::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); -} +mod helpers; mod about_variables; #[derive(Debug, StructOpt)]