Organize code into separate files

This commit is contained in:
Cameron Cordes
2020-05-19 22:44:26 -04:00
parent 0daa2f4149
commit 263dad91da
6 changed files with 99 additions and 74 deletions

28
src/filematch.rs Normal file
View File

@@ -0,0 +1,28 @@
use super::config::Config;
use super::printer::*;
#[derive(Debug)]
pub struct FileMatch {
pub file_name: String,
pub matches: Vec<Match>,
}
impl FileMatch {
pub fn print(&self, config: &Config) {
let cp = ColorPrinter {};
cp.print(&config, &self);
}
}
#[derive(Debug, Clone)]
pub struct Match {
pub line_number: usize,
pub match_indexes: Vec<MatchIndex>,
pub text: String,
}
#[derive(Debug, Clone)]
pub struct MatchIndex {
pub start: usize,
pub end: usize,
}