@@ -25,54 +25,45 @@ pub enum Term<V: Version> {
2525// Base methods.
2626impl < V : Version > Term < V > {
2727 /// A term that is always true.
28- pub fn any ( ) -> Self {
28+ pub ( crate ) fn any ( ) -> Self {
2929 Self :: Negative ( Range :: none ( ) )
3030 }
3131
3232 /// A term that is never true.
33- pub fn empty ( ) -> Self {
33+ pub ( crate ) fn empty ( ) -> Self {
3434 Self :: Positive ( Range :: none ( ) )
3535 }
3636
3737 /// A positive term containing exactly that version.
38- pub fn exact ( version : V ) -> Self {
38+ pub ( crate ) fn exact ( version : V ) -> Self {
3939 Self :: Positive ( Range :: exact ( version) )
4040 }
4141
4242 /// Simply check if a term is positive.
43- pub fn is_positive ( & self ) -> bool {
43+ pub ( crate ) fn is_positive ( & self ) -> bool {
4444 match self {
4545 Self :: Positive ( _) => true ,
4646 Self :: Negative ( _) => false ,
4747 }
4848 }
4949
5050 /// Simply check if a term is negative.
51- pub fn is_negative ( & self ) -> bool {
51+ pub ( crate ) fn is_negative ( & self ) -> bool {
5252 !self . is_positive ( )
5353 }
5454
5555 /// Negate a term.
5656 /// Evaluation of a negated term always returns
5757 /// the opposite of the evaluation of the original one.
58- pub fn negate ( & self ) -> Self {
58+ pub ( crate ) fn negate ( & self ) -> Self {
5959 match self {
6060 Self :: Positive ( range) => Self :: Negative ( range. clone ( ) ) ,
6161 Self :: Negative ( range) => Self :: Positive ( range. clone ( ) ) ,
6262 }
6363 }
6464
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-
7465 /// 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 {
7667 match self {
7768 Self :: Positive ( range) => range. contains ( v) ,
7869 Self :: Negative ( range) => !( range. contains ( v) ) ,
@@ -84,7 +75,7 @@ impl<V: Version> Term<V> {
8475impl < V : Version > Term < V > {
8576 /// Compute the intersection of two terms.
8677 /// 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 > {
8879 match ( self , other) {
8980 ( Self :: Positive ( r1) , Self :: Positive ( r2) ) => Self :: Positive ( r1. intersection ( r2) ) ,
9081 ( Self :: Positive ( r1) , Self :: Negative ( r2) ) => {
@@ -99,20 +90,20 @@ impl<V: Version> Term<V> {
9990
10091 /// Compute the union of two terms.
10192 /// 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 > {
10394 ( self . negate ( ) . intersection ( & other. negate ( ) ) ) . negate ( )
10495 }
10596
10697 /// Compute the intersection of multiple terms.
10798 /// 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 > {
109100 all_terms. fold ( Self :: any ( ) , |acc, term| acc. intersection ( term. as_ref ( ) ) )
110101 }
111102
112103 /// Indicate if this term is a subset of another term.
113104 /// Just like for sets, we say that t1 is a subset of t2
114105 /// 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 {
116107 self == & self . intersection ( other)
117108 }
118109}
@@ -121,7 +112,7 @@ impl<V: Version> Term<V> {
121112///
122113/// As a shorthand, we say that a term v
123114/// satisfies or contradicts a term t if {v} satisfies or contradicts it.
124- pub enum Relation {
115+ pub ( crate ) enum Relation {
125116 /// We say that a set of terms S "satisfies" a term t
126117 /// if t must be true whenever every term in S is true.
127118 Satisfied ,
@@ -141,7 +132,7 @@ impl<'a, V: 'a + Version> Term<V> {
141132 ///
142133 /// It turns out that this can also be expressed with set operations:
143134 /// S satisfies t if and only if ⋂ S ⊆ t
144- #[ allow ( dead_code ) ] // Used by proptest
135+ #[ cfg ( test ) ]
145136 fn satisfied_by ( & self , terms : impl Iterator < Item = & ' a Term < V > > ) -> bool {
146137 Self :: intersect_all ( terms) . subset_of ( self )
147138 }
@@ -154,14 +145,14 @@ impl<'a, V: 'a + Version> Term<V> {
154145 /// It turns out that this can also be expressed with set operations:
155146 /// S contradicts t if and only if ⋂ S is disjoint with t
156147 /// S contradicts t if and only if (⋂ S) ⋂ t = ∅
157- #[ allow ( dead_code ) ] // Used by proptest
148+ #[ cfg ( test ) ]
158149 fn contradicted_by ( & self , terms : impl Iterator < Item = & ' a Term < V > > ) -> bool {
159150 Self :: intersect_all ( terms) . intersection ( self ) == Self :: empty ( )
160151 }
161152
162153 /// Check if a set of terms satisfies or contradicts a given term.
163154 /// Otherwise the relation is inconclusive.
164- pub fn relation_with < T : AsRef < Term < V > > > (
155+ pub ( crate ) fn relation_with < T : AsRef < Term < V > > > (
165156 & self ,
166157 other_terms : impl Iterator < Item = T > ,
167158 ) -> Relation {
0 commit comments