Trait number_based::NumberBase
source · 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