Trait rbatis_codegen::ops::PartialOrd
source · pub trait PartialOrd<Rhs: ?Sized = Self> {
// Required method
fn op_partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
// Provided methods
fn op_lt(&self, other: &Rhs) -> bool { ... }
fn op_le(&self, other: &Rhs) -> bool { ... }
fn op_gt(&self, other: &Rhs) -> bool { ... }
fn op_ge(&self, other: &Rhs) -> bool { ... }
}
Required Methods§
sourcefn op_partial_cmp(&self, other: &Rhs) -> Option<Ordering>
fn op_partial_cmp(&self, other: &Rhs) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists.
§Examples
use std::cmp::Ordering;
use rbatis_codegen::ops::PartialOrd;
let result = 1.0.op_partial_cmp(&2.0);
assert_eq!(result, Some(Ordering::Less));
let result = 1.0.op_partial_cmp(&1.0);
assert_eq!(result, Some(Ordering::Equal));
let result = 2.0.op_partial_cmp(&1.0);
assert_eq!(result, Some(Ordering::Greater));
When comparison is impossible:
use rbatis_codegen::ops::PartialOrd;
let result = f64::NAN.op_partial_cmp(&1.0);
assert_eq!(result, None);
Provided Methods§
sourcefn op_lt(&self, other: &Rhs) -> bool
fn op_lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator.
§Examples
let result = 1.0 < 2.0;
assert_eq!(result, true);
let result = 2.0 < 1.0;
assert_eq!(result, false);
sourcefn op_le(&self, other: &Rhs) -> bool
fn op_le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator.
§Examples
let result = 1.0 <= 2.0;
assert_eq!(result, true);
let result = 2.0 <= 2.0;
assert_eq!(result, true);