@@ -25,54 +25,45 @@ pub enum Term<V: Version> {
25
25
// Base methods.
26
26
impl < V : Version > Term < V > {
27
27
/// A term that is always true.
28
- pub fn any ( ) -> Self {
28
+ pub ( crate ) fn any ( ) -> Self {
29
29
Self :: Negative ( Range :: none ( ) )
30
30
}
31
31
32
32
/// A term that is never true.
33
- pub fn empty ( ) -> Self {
33
+ pub ( crate ) fn empty ( ) -> Self {
34
34
Self :: Positive ( Range :: none ( ) )
35
35
}
36
36
37
37
/// A positive term containing exactly that version.
38
- pub fn exact ( version : V ) -> Self {
38
+ pub ( crate ) fn exact ( version : V ) -> Self {
39
39
Self :: Positive ( Range :: exact ( version) )
40
40
}
41
41
42
42
/// Simply check if a term is positive.
43
- pub fn is_positive ( & self ) -> bool {
43
+ pub ( crate ) fn is_positive ( & self ) -> bool {
44
44
match self {
45
45
Self :: Positive ( _) => true ,
46
46
Self :: Negative ( _) => false ,
47
47
}
48
48
}
49
49
50
50
/// Simply check if a term is negative.
51
- pub fn is_negative ( & self ) -> bool {
51
+ pub ( crate ) fn is_negative ( & self ) -> bool {
52
52
!self . is_positive ( )
53
53
}
54
54
55
55
/// Negate a term.
56
56
/// Evaluation of a negated term always returns
57
57
/// the opposite of the evaluation of the original one.
58
- pub fn negate ( & self ) -> Self {
58
+ pub ( crate ) fn negate ( & self ) -> Self {
59
59
match self {
60
60
Self :: Positive ( range) => Self :: Negative ( range. clone ( ) ) ,
61
61
Self :: Negative ( range) => Self :: Positive ( range. clone ( ) ) ,
62
62
}
63
63
}
64
64
65
- /// Evaluate a term regarding a given choice (or absence) of version.
66
- pub fn accept_optional_version ( & self , v_option : & Option < V > ) -> bool {
67
- match ( self , v_option) {
68
- ( Self :: Negative ( _) , None ) => true ,
69
- ( Self :: Positive ( _) , None ) => false ,
70
- ( _, Some ( v) ) => self . accept_version ( v) ,
71
- }
72
- }
73
-
74
65
/// Evaluate a term regarding a given choice of version.
75
- pub fn accept_version ( & self , v : & V ) -> bool {
66
+ pub ( crate ) fn accept_version ( & self , v : & V ) -> bool {
76
67
match self {
77
68
Self :: Positive ( range) => range. contains ( v) ,
78
69
Self :: Negative ( range) => !( range. contains ( v) ) ,
@@ -84,7 +75,7 @@ impl<V: Version> Term<V> {
84
75
impl < V : Version > Term < V > {
85
76
/// Compute the intersection of two terms.
86
77
/// If at least one term is positive, the intersection is also positive.
87
- pub fn intersection ( & self , other : & Term < V > ) -> Term < V > {
78
+ pub ( crate ) fn intersection ( & self , other : & Term < V > ) -> Term < V > {
88
79
match ( self , other) {
89
80
( Self :: Positive ( r1) , Self :: Positive ( r2) ) => Self :: Positive ( r1. intersection ( r2) ) ,
90
81
( Self :: Positive ( r1) , Self :: Negative ( r2) ) => {
@@ -99,20 +90,20 @@ impl<V: Version> Term<V> {
99
90
100
91
/// Compute the union of two terms.
101
92
/// If at least one term is negative, the union is also negative.
102
- pub fn union ( & self , other : & Term < V > ) -> Term < V > {
93
+ pub ( crate ) fn union ( & self , other : & Term < V > ) -> Term < V > {
103
94
( self . negate ( ) . intersection ( & other. negate ( ) ) ) . negate ( )
104
95
}
105
96
106
97
/// Compute the intersection of multiple terms.
107
98
/// Return None if the iterator is empty.
108
- pub fn intersect_all < T : AsRef < Term < V > > > ( all_terms : impl Iterator < Item = T > ) -> Term < V > {
99
+ pub ( crate ) fn intersect_all < T : AsRef < Term < V > > > ( all_terms : impl Iterator < Item = T > ) -> Term < V > {
109
100
all_terms. fold ( Self :: any ( ) , |acc, term| acc. intersection ( term. as_ref ( ) ) )
110
101
}
111
102
112
103
/// Indicate if this term is a subset of another term.
113
104
/// Just like for sets, we say that t1 is a subset of t2
114
105
/// if and only if t1 ∩ t2 = t1.
115
- pub fn subset_of ( & self , other : & Term < V > ) -> bool {
106
+ pub ( crate ) fn subset_of ( & self , other : & Term < V > ) -> bool {
116
107
self == & self . intersection ( other)
117
108
}
118
109
}
@@ -121,7 +112,7 @@ impl<V: Version> Term<V> {
121
112
///
122
113
/// As a shorthand, we say that a term v
123
114
/// satisfies or contradicts a term t if {v} satisfies or contradicts it.
124
- pub enum Relation {
115
+ pub ( crate ) enum Relation {
125
116
/// We say that a set of terms S "satisfies" a term t
126
117
/// if t must be true whenever every term in S is true.
127
118
Satisfied ,
@@ -141,7 +132,7 @@ impl<'a, V: 'a + Version> Term<V> {
141
132
///
142
133
/// It turns out that this can also be expressed with set operations:
143
134
/// S satisfies t if and only if ⋂ S ⊆ t
144
- #[ allow ( dead_code ) ] // Used by proptest
135
+ #[ cfg ( test ) ]
145
136
fn satisfied_by ( & self , terms : impl Iterator < Item = & ' a Term < V > > ) -> bool {
146
137
Self :: intersect_all ( terms) . subset_of ( self )
147
138
}
@@ -154,14 +145,14 @@ impl<'a, V: 'a + Version> Term<V> {
154
145
/// It turns out that this can also be expressed with set operations:
155
146
/// S contradicts t if and only if ⋂ S is disjoint with t
156
147
/// S contradicts t if and only if (⋂ S) ⋂ t = ∅
157
- #[ allow ( dead_code ) ] // Used by proptest
148
+ #[ cfg ( test ) ]
158
149
fn contradicted_by ( & self , terms : impl Iterator < Item = & ' a Term < V > > ) -> bool {
159
150
Self :: intersect_all ( terms) . intersection ( self ) == Self :: empty ( )
160
151
}
161
152
162
153
/// Check if a set of terms satisfies or contradicts a given term.
163
154
/// Otherwise the relation is inconclusive.
164
- pub fn relation_with < T : AsRef < Term < V > > > (
155
+ pub ( crate ) fn relation_with < T : AsRef < Term < V > > > (
165
156
& self ,
166
157
other_terms : impl Iterator < Item = T > ,
167
158
) -> Relation {
0 commit comments