[][src]Struct rug::complex::OrdComplex

#[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 core::cmp::Ordering;
use rug::{complex::OrdComplex, float::Special, Complex};

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);

Implementations

impl OrdComplex[src]

pub fn as_complex(&self) -> &Complex[src]

Extracts the underlying Complex.

The same result can be obtained using the implementation of AsRef<Complex> which is provided for OrdComplex.

Examples

use rug::{complex::OrdComplex, 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]

Extracts the underlying Complex.

The same result can be obtained using the implementation of AsMut<Complex> which is provided for OrdComplex.

Examples

use rug::{complex::OrdComplex, Complex};
let c = Complex::with_val(53, (1.5, -2.5));
let mut ord = OrdComplex::from(c);
ord.as_complex_mut().conj_mut();
let c_ref = ord.as_complex();
assert_eq!(*c_ref.real(), 1.5);
assert_eq!(*c_ref.imag(), 2.5);

Trait Implementations

impl AsMut<Complex> for OrdComplex[src]

impl AsRef<Complex> for OrdComplex[src]

impl AsRef<OrdComplex> for Complex[src]

impl Clone for OrdComplex[src]

impl Debug for OrdComplex[src]

impl<'de> Deserialize<'de> for OrdComplex[src]

impl Eq for OrdComplex[src]

impl From<Complex> for OrdComplex[src]

impl From<OrdComplex> for Complex[src]

impl Hash for OrdComplex[src]

impl Ord for OrdComplex[src]

impl PartialEq<OrdComplex> for OrdComplex[src]

impl PartialOrd<OrdComplex> for OrdComplex[src]

impl Serialize for OrdComplex[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Az for T[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CheckedAs for T[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> OverflowingAs for T[src]

impl<T> SaturatingAs for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WrappingAs for T[src]