pub trait NumberBase:
Add
+ Sub
+ Div
+ Mul
+ Display
+ Sized
+ Clone {
type DecimalType;
// Required methods
fn base(&self) -> u16;
fn greater_than(&self, number: Self) -> bool;
fn digits(&self) -> &Vec<u16>;
fn from_string(base: u16, number: &str) -> Self;
fn from_vec(base: u16, number: Vec<u16>) -> Self;
fn convert(&mut self, base: u16) -> Self;
fn display(&self) -> String;
fn as_binary(&self) -> Self::DecimalType;
fn as_octal(&self) -> Self::DecimalType;
fn as_decimal(&self) -> Self::DecimalType;
fn as_hex(&self) -> String;
}Required Associated Types§
Sourcetype DecimalType
type DecimalType
The type being returned when a decimal is to be returned For instance, the as_octal() function returns either an integer or float depending on whether the struct implementing NumberBase only accepts integers
Required Methods§
Sourcefn greater_than(&self, number: Self) -> bool
fn greater_than(&self, number: Self) -> bool
returns true if the number is greater than the input for this funciton
Sourcefn from_string(base: u16, number: &str) -> Self
fn from_string(base: u16, number: &str) -> Self
creates an instance of Self from a string
Sourcefn as_binary(&self) -> Self::DecimalType
fn as_binary(&self) -> Self::DecimalType
returns an instance of self but in binary
Sourcefn as_octal(&self) -> Self::DecimalType
fn as_octal(&self) -> Self::DecimalType
returns an instance of self but in octal
Sourcefn as_decimal(&self) -> Self::DecimalType
fn as_decimal(&self) -> Self::DecimalType
returns an instance of self but in decimal
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".