Skip to content

Commit fb63fee

Browse files
committed
refactoring
1 parent 648c506 commit fb63fee

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/rule/collection/exists.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::{HashMap, HashSet, VecDeque};
22

33
use crate::rule::composer::Not;
4-
use crate::rule::{ForAllRule, Iterable, Rule};
4+
use crate::rule::{ForAllRule, Rule};
55
use crate::Refined;
66

77
/// A type that holds a value satisfying the `ExistsRule`
@@ -23,8 +23,7 @@ pub type ExistsHashMap<K, RULE> = Refined<ExistsHashMapRule<K, RULE>>;
2323
pub type ExistsString<RULE> = Refined<ExistsStringRule<RULE>>;
2424

2525
/// Rule where at least one data in the collection satisfies the condition
26-
pub type ExistsRule<RULE, ITERABLE> =
27-
Not<ForAllRule<Not<RULE>, ITERABLE, <ITERABLE as Iterable>::Item>>;
26+
pub type ExistsRule<RULE, ITERABLE> = Not<ForAllRule<Not<RULE>, ITERABLE>>;
2827

2928
/// Rule where at least one data in the `Vec` satisfies the condition
3029
pub type ExistsVecRule<RULE> = ExistsRule<RULE, Vec<<RULE as Rule>::Item>>;

src/rule/collection/for_all.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::collections::{HashMap, HashSet, VecDeque};
22

3-
use crate::rule::{NoSkip, Rule, SkipRule};
3+
use crate::rule::{Iterable, NoSkip, Rule, SkipRule};
44
use crate::Refined;
55

66
/// A type that holds a value satisfying the `ForAllRule`
7-
pub type ForAll<RULE, ITERABLE, ITEM> = Refined<ForAllRule<RULE, ITERABLE, ITEM>>;
7+
pub type ForAll<RULE, ITERABLE> = Refined<ForAllRule<RULE, ITERABLE>>;
88

99
/// A type that holds a Vec value satisfying the `ForAllRule`
1010
pub type ForAllVec<RULE> = Refined<ForAllVecRule<RULE>>;
@@ -22,25 +22,23 @@ pub type ForAllHashMap<K, RULE> = Refined<ForAllHashMapRule<K, RULE>>;
2222
pub type ForAllString<RULE> = Refined<ForAllStringRule<RULE>>;
2323

2424
/// Rule where all the data in the collection satisfies the condition
25-
pub type ForAllRule<RULE, ITERABLE, ITEM> = SkipRule<RULE, ITERABLE, NoSkip<ITEM>>;
25+
pub type ForAllRule<RULE, ITERABLE> =
26+
SkipRule<RULE, ITERABLE, NoSkip<<ITERABLE as Iterable>::Item>>;
2627

2728
/// Rule where all the data in the `Vec` satisfies the condition
28-
pub type ForAllVecRule<RULE> = ForAllRule<RULE, Vec<<RULE as Rule>::Item>, <RULE as Rule>::Item>;
29+
pub type ForAllVecRule<RULE> = ForAllRule<RULE, Vec<<RULE as Rule>::Item>>;
2930

3031
/// Rule where all the data in the `VecDeque` satisfies the condition
31-
pub type ForAllVecDequeRule<RULE> =
32-
ForAllRule<RULE, VecDeque<<RULE as Rule>::Item>, <RULE as Rule>::Item>;
32+
pub type ForAllVecDequeRule<RULE> = ForAllRule<RULE, VecDeque<<RULE as Rule>::Item>>;
3333

3434
/// Rule where all the data in the `HashSet` satisfies the condition
35-
pub type ForAllHashSetRule<RULE> =
36-
ForAllRule<RULE, HashSet<<RULE as Rule>::Item>, <RULE as Rule>::Item>;
35+
pub type ForAllHashSetRule<RULE> = ForAllRule<RULE, HashSet<<RULE as Rule>::Item>>;
3736

3837
/// Rule where all the data in the `HashMap` satisfies the condition
39-
pub type ForAllHashMapRule<K, RULE> =
40-
ForAllRule<RULE, HashMap<K, <RULE as Rule>::Item>, <RULE as Rule>::Item>;
38+
pub type ForAllHashMapRule<K, RULE> = ForAllRule<RULE, HashMap<K, <RULE as Rule>::Item>>;
4139

4240
/// Rule where all the data in the `String` satisfies the condition
43-
pub type ForAllStringRule<RULE> = ForAllRule<RULE, String, char>;
41+
pub type ForAllStringRule<RULE> = ForAllRule<RULE, String>;
4442

4543
#[cfg(test)]
4644
mod tests {

src/rule/collection/reverse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::Refined;
44
use std::marker::PhantomData;
55

66
/// A type that holds a value satisfying the `ReverseRule`
7-
pub type Reverse<'a, RULE> = Refined<ReverseRule<RULE>>;
7+
pub type Reverse<RULE> = Refined<ReverseRule<RULE>>;
88

99
/// Rule where the data in the collection satisfies the condition after reversing
1010
pub struct ReverseRule<RULE>

0 commit comments

Comments
 (0)