From 7d4d9a8824f5154e590cd70063418ade71d3e8dd Mon Sep 17 00:00:00 2001 From: graelo Date: Sat, 20 Mar 2021 07:06:33 +0100 Subject: [PATCH] refactor: Match -> textbuf/matches.rs --- src/textbuf/matches.rs | 10 ++++++++++ src/textbuf/mod.rs | 4 +++- src/textbuf/model.rs | 12 +----------- 3 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 src/textbuf/matches.rs diff --git a/src/textbuf/matches.rs b/src/textbuf/matches.rs new file mode 100644 index 0000000..1695605 --- /dev/null +++ b/src/textbuf/matches.rs @@ -0,0 +1,10 @@ +/// Represents matched text, its location on screen, the pattern that created +/// it, and the associated hint. +#[derive(Debug)] +pub struct Match<'a> { + pub x: i32, + pub y: i32, + pub pattern: &'a str, + pub text: &'a str, + pub hint: String, +} diff --git a/src/textbuf/mod.rs b/src/textbuf/mod.rs index 646ee07..6d912bd 100644 --- a/src/textbuf/mod.rs +++ b/src/textbuf/mod.rs @@ -1,4 +1,6 @@ +mod matches; mod model; mod raw_match; -pub use model::{Match, Model}; +pub use matches::Match; +pub use model::Model; diff --git a/src/textbuf/model.rs b/src/textbuf/model.rs index f0cb2f7..a8ee610 100644 --- a/src/textbuf/model.rs +++ b/src/textbuf/model.rs @@ -3,6 +3,7 @@ use std::collections; use regex::Regex; use sequence_trie::SequenceTrie; +use super::matches::Match; use super::raw_match::RawMatch; use crate::alphabets::Alphabet; use crate::regexes::{NamedPattern, EXCLUDE_PATTERNS, PATTERNS}; @@ -228,17 +229,6 @@ impl<'a> Model<'a> { } } -/// Represents matched text, its location on screen, the pattern that created -/// it, and the associated hint. -#[derive(Debug)] -pub struct Match<'a> { - pub x: i32, - pub y: i32, - pub pattern: &'a str, - pub text: &'a str, - pub hint: String, -} - #[cfg(test)] mod tests { use super::*;