Trait digits_iterator::DigitsExtension [−][src]
pub trait DigitsExtension: Int { fn digits(self) -> Digits<Self> { ... } fn digits_with_base(self, base: u32) -> Digits<Self> { ... } }
Adds the extension methods to iterate over the digits of integers.
Provided Methods
fn digits(self) -> Digits<Self>
Iterates over the digits of self in decimal base.
Example
use digits_iterator::*; let n = 2018_u32; let digits: Vec<_> = n.digits().collect(); assert_eq!(digits, [2, 0, 1, 8]);
fn digits_with_base(self, base: u32) -> Digits<Self>
Iterates over the digits of self in a base between 2 and 36.
Example
use digits_iterator::*; let n = 0b100101_u32; let digits: Vec<_> = n.digits_with_base(2).collect(); assert_eq!(digits, [1, 0, 0, 1, 0, 1]);
Implementors
impl<T> DigitsExtension for T where
T: Int,