pub enum Operator {
Equal,
EqualStar,
ExactEqual,
NotEqual,
NotEqualStar,
TildeEqual,
LessThan,
LessThanEqual,
GreaterThan,
GreaterThanEqual,
}Expand description
One of ~= == != <= >= < > ===
Variants§
Equal
== 1.2.3
EqualStar
== 1.2.*
ExactEqual
=== (discouraged)
https://peps.python.org/pep-0440/#arbitrary-equality
“Use of this operator is heavily discouraged and tooling MAY display a warning when it is used”
NotEqual
!= 1.2.3
NotEqualStar
!= 1.2.*
TildeEqual
~=
Invariant: With ~=, there are always at least 2 release segments.
LessThan
<
LessThanEqual
<=
GreaterThan
>
GreaterThanEqual
>=
Implementations§
Source§impl Operator
impl Operator
Sourcepub fn negate(self) -> Option<Self>
pub fn negate(self) -> Option<Self>
Negates this operator, if a negation exists, so that it has the opposite meaning.
This returns a negated operator in every case except for the ~=
operator. In that case, None is returned and callers may need to
handle its negation at a higher level. (For example, if it’s negated
in the context of a marker expression, then the “compatible” version
constraint can be split into its component parts and turned into a
disjunction of the negation of each of those parts.)
Note that this routine is not reversible in all cases. For example
Operator::ExactEqual negates to Operator::NotEqual, and
Operator::NotEqual in turn negates to Operator::Equal.