[][src]Struct surreal::Surreal

pub struct Surreal { /* fields omitted */ }

A struct to represent surreal numbers with non-infinite sets.

N.B. Currently, multiplication does not work for numbers on or after day 4.

Methods

impl Surreal[src]

pub fn new(left: Vec<&Surreal>, right: Vec<&Surreal>) -> Surreal[src]

Creates a new surreal number given two vectors of references to surreal numbers. Each vector corresponds to a left set and a right set, where each number in the left set must be less than all numbers in the right set.

Panics

Panics if any Surreal in left is greater than or equal to any Surreal in right.

Examples

// the lines below will compile
let zero = surreal::Surreal::new(vec![], vec![]);
let one = surreal::Surreal::new(vec![&zero], vec![]);
let neg_one = surreal::Surreal::new(vec![], vec![&zero]);

// the lines below will panic
// let err = surreal::Surreal::new(vec![&one], vec![&neg_one]);
// let err = surreal::Surreal::new(vec![&zero], vec![&zero]);

pub fn left(&self) -> Vec<Surreal>[src]

Returns the left set of a surreal number (as a Vec<Surreal> instead of a Vec<&Surreal>).

Examples

let zero = surreal::Surreal::new(vec![], vec![]);
let one = surreal::Surreal::new(vec![&zero], vec![]);

assert!(zero.left().is_empty());
assert!(one.left()[0] == zero);

pub fn right(&self) -> Vec<Surreal>[src]

Returns the right set of a surreal number (as a Vec<Surreal> instead of a Vec<&Surreal>).

Examples

let zero = surreal::Surreal::new(vec![], vec![]);
let neg_one = surreal::Surreal::new(vec![], vec![&zero]);

assert!(zero.right().is_empty());
assert!(neg_one.right()[0] == zero);

Trait Implementations

impl PartialEq<Surreal> for Surreal[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Clone for Surreal[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialOrd<Surreal> for Surreal[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Eq for Surreal[src]

impl Display for Surreal[src]

impl Debug for Surreal[src]

impl<'a, 'b> Add<&'b Surreal> for &'a Surreal[src]

type Output = Surreal

The resulting type after applying the + operator.

impl<'a, 'b> Sub<&'b Surreal> for &'a Surreal[src]

type Output = Surreal

The resulting type after applying the - operator.

impl<'a, 'b> Mul<&'b Surreal> for &'a Surreal[src]

type Output = Surreal

The resulting type after applying the * operator.

impl<'a> Neg for &'a Surreal[src]

type Output = Surreal

The resulting type after applying the - operator.

Auto Trait Implementations

impl Unpin for Surreal

impl Sync for Surreal

impl Send for Surreal

impl RefUnwindSafe for Surreal

impl UnwindSafe for Surreal

Blanket Implementations

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

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

type Owned = T

The resulting type after obtaining ownership.

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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