pub trait Operator<T> {
// Required method
fn apply(&self, value: &T) -> bool;
// Provided methods
fn empty_collection(&self) -> bool { ... }
fn null_option(&self) -> bool { ... }
}
filter
only.Expand description
Take a single value and produce a true/false result.
Operators are generally applied by Operable
types, so the
operators themselves can be naive with respect to things like
Option<T>
and collections. For operators that need to know about
special cases, there are the inelegant get-out functions
empty_collection
and
null_option
which can be
implemented. Both return false
by default.
The standard Django operators are in the
ops
module. Examples are
exact
,
in
,
contains
and so forth.
Required Methods§
Provided Methods§
Sourcefn empty_collection(&self) -> bool
fn empty_collection(&self) -> bool
Return a value for this operator when applied to an empty
collection. Implicitly, operators are distributed over
collections with any
semantics, so that any true
result
means the collection evaluates to true
. The default
behaviour for this method is to return false
, which is
consistent with those semantics.
Sourcefn null_option(&self) -> bool
fn null_option(&self) -> bool
Return a value for this operator when applied to a None
value wrapping its target type (e.g. for an operator on T, we
are determining the behaviour on Optionfalse
for None
(e.g for. isnull
).