Struct digits::Digits [] [src]

pub struct Digits<'a> { /* fields omitted */ }

This struct acts similar to a full number with a custom numeric character base. But the underlying implementation is a linked list where all the methods recurse as far as need to to implement the operations.

Methods

impl<'a> Digits<'a>
[src]

[src]

Add two Digits instances together. This will panic if the two Digits don't share the same numeric base.

Example

use digits::{BaseCustom,Digits};

let base10 = BaseCustom::<char>::new("0123456789".chars().collect());

let mut eleven = Digits::new(&base10, "11".to_string());
let two = Digits::new(&base10, "2".to_string());

assert_eq!(eleven.add(two).to_s(), "13");

Output

"13"

[src]

Allows you to generate/encode a Digits from a u64 or other Digits even if they are of a different numeric base.

Example

use digits::{BaseCustom,Digits};

let base10 = BaseCustom::<char>::new("0123456789".chars().collect());

let two = Digits::new(&base10, "2".to_string());
let three = two.gen(3_u64);

assert_eq!(three.to_s(), "3");

[src]

Returns bool value of if the number is one.

[src]

Returns bool value of if the number is zero.

[src]

Returns a usize of the total linked list length.

[src]

Multiply two Digits instances together. This will panic if the two Digits don't share the same numeric base.

Example

use digits::{BaseCustom,Digits};

let base10 = BaseCustom::<char>::new("0123456789".chars().collect());

let mut eleven = Digits::new(&base10, "11".to_string());
let two = Digits::new(&base10, "2".to_string());

assert_eq!(eleven.mul(two).to_s(), "22");

Output

"22"

[src]

Add two Digits instances together. This will panic if the two Digits don't share the same numeric base.

Example

use digits::{BaseCustom,Digits};

let base10 = BaseCustom::<char>::new("0123456789".chars().collect());

let mut eleven = Digits::new(&base10, "11".to_string());
let two = Digits::new(&base10, "2".to_string());

assert_eq!(eleven.mut_add(two).to_s(), "13");

Output

"13"

[src]

Multiply two Digits instances together. This will panic if the two Digits don't share the same numeric base.

Example

use digits::{BaseCustom,Digits};

let base10 = BaseCustom::<char>::new("0123456789".chars().collect());

let mut eleven = Digits::new(&base10, "11".to_string());
let two = Digits::new(&base10, "2".to_string());

assert_eq!(eleven.mut_mul(two).to_s(), "22");

Output

"22"

[src]

Creates a new Digits instance with the provided character set and value.

The first parameter must be a BaseCustom object which defines and maps all values. The second parameter is a string value with all valid characters from the BaseCustom set.

[src]

Creates a new Digits instance with value of one and the provided character mapping.

[src]

Creates a new Digits instance with value of zero and uses the provided character mapping.

[src]

Creates a new Digits instance with value of one and uses the current character mapping.

[src]

The “pinky” is the smallest digit a.k.a. current digit in the linked list a.k.a. the right most digit. This will be a char value for that digit.

[src]

Multiplies self times the power-of given Digits parameter.

Example

use digits::{BaseCustom,Digits};

let base10 = BaseCustom::<char>::new("0123456789".chars().collect());

let mut eleven = Digits::new(&base10, "11".to_string());
let two = Digits::new(&base10, "2".to_string());

assert_eq!(eleven.pow(two).to_s(), "121");

Output

"121"

[src]

Minuses one unless it's zero, then it just returns a Digits instance of zero.

[src]

Creates a new Digits instance with the internal character set and given value.

The parameter is a string value with all valid characters from the BaseCustom set.

[src]

An alias for clone. Useful for unboxing.

[src]

Plus one.

[src]

Gives the full value of all digits within the linked list as a String.

[src]

Gives the full value of all digits within the linked list as a String.

[src]

Creates a new Digits instance with value of zero and the current character mapping.

Trait Implementations

impl<'a> Clone for Digits<'a>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> From<(&'a BaseCustom<char>, u64)> for Digits<'a>
[src]

[src]

Performs the conversion.

impl<'a, 'b> From<(&'a BaseCustom<char>, Digits<'b>)> for Digits<'a>
[src]

[src]

Performs the conversion.

impl<'a, 'b> From<(Digits<'a>, Digits<'b>)> for Digits<'a>
[src]

[src]

Performs the conversion.

impl<'a> Into<String> for Digits<'a>
[src]

[src]

impl<'a> Display for Digits<'a>
[src]

[src]

Formats the value using the given formatter. Read more

impl<'a> Debug for Digits<'a>
[src]

[src]

Formats the value using the given formatter.

impl<'a> PartialEq for Digits<'a>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<'a> Add for Digits<'a>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a> AddAssign for Digits<'a>
[src]

[src]

Performs the += operation.

impl<'a> Mul for Digits<'a>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a> MulAssign for Digits<'a>
[src]

[src]

Performs the *= operation.

impl<'a> BitXor for Digits<'a>
[src]

The resulting type after applying the ^ operator.

[src]

Performs the ^ operation.

impl<'a> BitXorAssign for Digits<'a>
[src]

[src]

Performs the ^= operation.

impl<'a> PartialOrd for Digits<'a>
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

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

1.0.0
[src]

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

1.0.0
[src]

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

1.0.0
[src]

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