Struct rug::complex::OrdComplex [−][src]
#[repr(transparent)]pub struct OrdComplex { /* fields omitted */ }
A complex number that supports total ordering and hashing.
For ordering, the real part has precedence over the imaginary part. Negative zero is ordered as less than positive zero. Negative NaN is ordered as less than negative infinity, while positive NaN is ordered as greater than positive infinity. Comparing two negative NaNs or two positive NaNs produces equality.
Examples
use rug::complex::OrdComplex; use rug::float::Special; use rug::Complex; use std::cmp::Ordering; let nan_c = Complex::with_val(53, (Special::Nan, Special::Nan)); let nan = OrdComplex::from(nan_c); assert_eq!(nan.cmp(&nan), Ordering::Equal); let one_neg0_c = Complex::with_val(53, (1, Special::NegZero)); let one_neg0 = OrdComplex::from(one_neg0_c); let one_pos0_c = Complex::with_val(53, (1, Special::Zero)); let one_pos0 = OrdComplex::from(one_pos0_c); assert_eq!(one_neg0.cmp(&one_pos0), Ordering::Less); let zero_inf_s = (Special::Zero, Special::Infinity); let zero_inf_c = Complex::with_val(53, zero_inf_s); let zero_inf = OrdComplex::from(zero_inf_c); assert_eq!(one_pos0.cmp(&zero_inf), Ordering::Greater);
Methods
impl OrdComplex
[src]
impl OrdComplex
pub fn as_complex(&self) -> &Complex
[src]
pub fn as_complex(&self) -> &Complex
Extracts the underlying Complex
.
Examples
use rug::complex::OrdComplex; use rug::Complex; let c = Complex::with_val(53, (1.5, 2.5)); let ord = OrdComplex::from(c); let c_ref = ord.as_complex(); assert_eq!(*c_ref.real(), 1.5); assert_eq!(*c_ref.imag(), 2.5);
pub fn as_complex_mut(&mut self) -> &mut Complex
[src]
pub fn as_complex_mut(&mut self) -> &mut Complex
Trait Implementations
impl Clone for OrdComplex
[src]
impl Clone for OrdComplex
fn clone(&self) -> OrdComplex
[src]
fn clone(&self) -> OrdComplex
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for OrdComplex
[src]
impl Debug for OrdComplex
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Hash for OrdComplex
[src]
impl Hash for OrdComplex
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Eq for OrdComplex
[src]
impl Eq for OrdComplex
impl Ord for OrdComplex
[src]
impl Ord for OrdComplex
fn cmp(&self, other: &OrdComplex) -> Ordering
[src]
fn cmp(&self, other: &OrdComplex) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl PartialEq for OrdComplex
[src]
impl PartialEq for OrdComplex
fn eq(&self, other: &OrdComplex) -> bool
[src]
fn eq(&self, other: &OrdComplex) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl PartialOrd for OrdComplex
[src]
impl PartialOrd for OrdComplex
fn partial_cmp(&self, other: &OrdComplex) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &OrdComplex) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl From<Complex> for OrdComplex
[src]
impl From<Complex> for OrdComplex
impl From<OrdComplex> for Complex
[src]
impl From<OrdComplex> for Complex
fn from(src: OrdComplex) -> Self
[src]
fn from(src: OrdComplex) -> Self
Performs the conversion.
impl Serialize for OrdComplex
[src]
impl Serialize for OrdComplex
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for OrdComplex
[src]
impl<'de> Deserialize<'de> for OrdComplex
fn deserialize<D>(deserializer: D) -> Result<OrdComplex, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<OrdComplex, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
fn deserialize_in_place<D>(
deserializer: D,
place: &mut OrdComplex
) -> Result<(), D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize_in_place<D>(
deserializer: D,
place: &mut OrdComplex
) -> Result<(), D::Error> where
D: Deserializer<'de>,
Auto Trait Implementations
impl Send for OrdComplex
impl Send for OrdComplex
impl Sync for OrdComplex
impl Sync for OrdComplex