[][src]Struct radixal::digits_iterator::DigitsIterator

pub struct DigitsIterator<T: IntoDigits> { /* fields omitted */ }

An iterator over the digits of a number.

For a given radix, iterates over the digits in big endian order, i.e. from most significant to least significant.

Methods

impl<T: IntoDigits> DigitsIterator<T>[src]

pub fn new(number: T, radix: T) -> Result<DigitsIterator<T>, RadixError>[src]

Create a new DigitsIterator for number using radix.

Returns an Err(RadixError) if the radix is 0 is 1.

Example

use radixal::digits_iterator::{DigitsIterator, RadixError};

let mut digits = DigitsIterator::new(123_u32, 10).unwrap();

assert_eq!(digits.next(), Some(1));
assert_eq!(digits.next(), Some(2));
assert_eq!(digits.next(), Some(3));
assert_eq!(digits.next(), None);

let mut digits = DigitsIterator::new(123_u32, 0);
assert_eq!(digits.unwrap_err(), RadixError::Radix0);

let mut digits = DigitsIterator::new(123_u32, 1);
assert_eq!(digits.unwrap_err(), RadixError::Radix1);

pub fn into_number(self) -> T[src]

Converts the DigitsIterator into a number.

pub fn into_reversed_number(self) -> T[src]

Converts the DigitsIterator into a number with the digits reversed, using wrapping semantics if necessary.

Trait Implementations

impl<T: IntoDigits> DoubleEndedIterator for DigitsIterator<T>[src]

impl<T: Eq + IntoDigits> Eq for DigitsIterator<T>[src]

impl<T: Clone + IntoDigits> Clone for DigitsIterator<T>[src]

impl<T: IntoDigits> ExactSizeIterator for DigitsIterator<T>[src]

impl<T: PartialEq + IntoDigits> PartialEq<DigitsIterator<T>> for DigitsIterator<T>[src]

impl<T: IntoDigits> Iterator for DigitsIterator<T>[src]

type Item = T

The type of the elements being iterated over.

impl<T: Debug + IntoDigits> Debug for DigitsIterator<T>[src]

impl<T: IntoDigits> FusedIterator for DigitsIterator<T>[src]

Auto Trait Implementations

impl<T> Send for DigitsIterator<T> where
    T: Send

impl<T> Unpin for DigitsIterator<T> where
    T: Unpin

impl<T> Sync for DigitsIterator<T> where
    T: Sync

impl<T> RefUnwindSafe for DigitsIterator<T> where
    T: RefUnwindSafe

impl<T> UnwindSafe for DigitsIterator<T> where
    T: UnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]