Struct digits::prelude::BaseCustom
source · [−]pub struct BaseCustom<T> {
pub base: u64,
/* private fields */
}
Expand description
The BaseCustom struct holds the information to perform number conversions
via the gen
and decimal
methods.
A new instance of BaseCustom can be created with either
BaseCustom::<char>::new(Vec<char>)
BaseCustom::<char>::from_ordinal_range(Range)
BaseCustom::<String>::new(String, Option<char>)
If you are going to provide a delimiter you need to use the <String>
implementation.
A delimiter is optional.
The primitives for BaseCustom get built from the provides characters or string groups and conversion methods are available to use then. String groupings will be single character strings if no delimiter is given, otherwise they may be strings of any length split only by the delimiter provided.
Fields
base: u64
The size of the base
Implementations
sourceimpl BaseCustom<char>
impl BaseCustom<char>
sourcepub fn new(chars: Vec<char, Global>) -> BaseCustom<char>
pub fn new(chars: Vec<char, Global>) -> BaseCustom<char>
‘new’ creates a new BaseCustom instance and propogates the values for converting numeric bases.
new
for BaseCustom<char>
requires a Vec<char>
as its parameters and units
for measuring the custom numeric base will only be one character long each.
sourcepub fn nth(&self, pos: usize) -> Option<&char>
pub fn nth(&self, pos: usize) -> Option<&char>
Returns the nth value of your custom base
Like most indexing operations, the count starts from zero, so nth(0) returns the first value, nth(1) the second, and so on.
sourcepub fn from_ordinal_range(range: Range<u32>) -> BaseCustom<char>
pub fn from_ordinal_range(range: Range<u32>) -> BaseCustom<char>
Create a custom numeric base from an ascii range of ordinal values
This method currently restricts the ascii character range of the
95 typical characters starting from 32 and ending with 127. If you’d
like to use characters outside of this range please use the new
method.
sourceimpl BaseCustom<String>
impl BaseCustom<String>
sourcepub fn new<S>(chars: S, delim: Option<char>) -> BaseCustom<String> where
S: Into<String>,
pub fn new<S>(chars: S, delim: Option<char>) -> BaseCustom<String> where
S: Into<String>,
‘new’ creates a new BaseCustom instance and propogates the values for converting numeric bases.
new
for BaseCustom<String>
requires a String
as its first parameter and units
for measuring the custom numeric base can be one character long, or many in length.
The second parameter is of Option<char>
is a delimiter option for determining whether
to split the string into single character length strings or possibly multiple length
if the delimiter is partitioning the string in such a way.
Trait Implementations
sourceimpl<T> Clone for BaseCustom<T> where
T: Clone,
impl<T> Clone for BaseCustom<T> where
T: Clone,
sourcefn clone(&self) -> BaseCustom<T>
fn clone(&self) -> BaseCustom<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BaseCustom<String>
impl Debug for BaseCustom<String>
sourceimpl Debug for BaseCustom<char>
impl Debug for BaseCustom<char>
sourceimpl PartialEq<BaseCustom<String>> for BaseCustom<String>
impl PartialEq<BaseCustom<String>> for BaseCustom<String>
Auto Trait Implementations
impl<T> RefUnwindSafe for BaseCustom<T> where
T: RefUnwindSafe,
impl<T> Send for BaseCustom<T> where
T: Send,
impl<T> Sync for BaseCustom<T> where
T: Sync,
impl<T> Unpin for BaseCustom<T> where
T: Unpin,
impl<T> UnwindSafe for BaseCustom<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more