Struct digits::Digits
[−]
[src]
pub struct Digits<'a> { /* fields omitted */ }
struct Digits
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]
fn new<S>(mapping: &'a BaseCustom<char>, number: S) -> Digits<'a> where
S: Into<String>,
S: Into<String>,
new
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.
You can view the numbers current value at any time with to_s()
or to_string()
.
fn replicate(self) -> Self
replicate
— alias for clone (useful for unboxing)
fn propagate<S>(&self, number: S) -> Self where
S: Into<String>,
S: Into<String>,
propagate
creates a new number from the same underlying numeric base
fn to_s(&self) -> String
Gives the full value of all digits within the linked list as a String.
fn to_string(&self) -> String
Gives the full value of all digits within the linked list as a String.
fn length(&self) -> usize
length
returns a usize
of the total linked list length.
fn zero(&self) -> Self
zero
returns a Digits instance with value of zero and the current character mapping.
fn new_zero(mapping: &'a BaseCustom<char>) -> Self
new_zero
returns a Digits instance with value of zero and the current character mapping.
fn is_zero(&self) -> bool
is_zero
returns bool value of if the number is zero
fn pinky(&self) -> char
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.
fn one(&self) -> Self
one
returns a Digits instance with value of one and the current character mapping.
fn new_one(mapping: &'a BaseCustom<char>) -> Self
new_one
returns a Digits instance with value of one and the current character mapping.
fn add(&mut self, other: Self) -> Self
Add two Digits instances together. The one the add
method is called on
must be mutable and modifies itself. The other is consumed.
Returns a clone of the updated Self
as well.
fn mul(&mut self, other: Self) -> Self
Multiply two Digits instances together. The one the mul
method is called on
must be mutable and modifies itself. The other is consumed.
Returns a clone of the updated Self
as well.
Trait Implementations
impl<'a> Clone for Digits<'a>
[src]
fn clone(&self) -> Digits<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more