summaryrefslogtreecommitdiffstats
path: root/cli/src/search.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-08-02 14:03:48 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-08-02 14:03:48 +0200
commit40d8e8fadd4aea081ecbb64b1dee43606e6b3efc (patch)
tree6f529b1ca280f3b6a5c7feedbd089564b7fcbc21 /cli/src/search.rs
parent661f1bd5575e139a51bad7f08061c677e00d8106 (diff)
downloadmoney-40d8e8fadd4aea081ecbb64b1dee43606e6b3efc.tar.gz
filtertype -> filter
Diffstat (limited to 'cli/src/search.rs')
-rw-r--r--cli/src/search.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/cli/src/search.rs b/cli/src/search.rs
index 7359b19..7fbb0a6 100644
--- a/cli/src/search.rs
+++ b/cli/src/search.rs
@@ -87,16 +87,16 @@ impl Constraint {
}
}
-enum FilterType {
+enum Filter {
Union(Constraint),
Intersect(Constraint),
Subtract(Constraint),
}
-impl FilterType {
+impl Filter {
fn apply<'s>(&self, mut search: Search<'s>) -> Search<'s> {
match self {
- FilterType::Union(constraint) => {
+ Filter::Union(constraint) => {
//TODO binary search and insert sorted
for idx in search
.transactions
@@ -110,7 +110,7 @@ impl FilterType {
search.filtered.sort();
search.filtered.dedup();
}
- FilterType::Intersect(constraint) => {
+ Filter::Intersect(constraint) => {
search.filtered = search
.filtered
.iter()
@@ -118,7 +118,7 @@ impl FilterType {
.copied()
.collect();
}
- FilterType::Subtract(constraint) => {
+ Filter::Subtract(constraint) => {
search.filtered = search
.filtered
.iter()
@@ -156,10 +156,10 @@ impl<'t> Search<'t> {
pub fn parse(mut self, rules: String) -> Self {
for rule in rules.split(' ') {
- let (filter_type, rule): (fn(Constraint) -> FilterType, &str) = match rule.chars().nth(0).unwrap() {
- '-' => (FilterType::Subtract, &rule[1..]),
- '+' => (FilterType::Union, &rule[1..]),
- _ => (FilterType::Intersect, &rule[..]),
+ let (filter, rule): (fn(Constraint) -> Filter, &str) = match rule.chars().nth(0).unwrap() {
+ '-' => (Filter::Subtract, &rule[1..]),
+ '+' => (Filter::Union, &rule[1..]),
+ _ => (Filter::Intersect, &rule[..]),
};
//TODO lexing? can do a function for "spaces inside" instead
@@ -178,7 +178,7 @@ impl<'t> Search<'t> {
_ => panic!(),
};
- self = filter_type(constraint).apply(self);
+ self = filter(constraint).apply(self);
}
self
}