integer-iterator

Crates.iointeger-iterator
lib.rsinteger-iterator
version0.3.0
sourcesrc
created_at2020-09-01 12:37:14.396762
updated_at2022-02-27 09:25:45.387823
descriptionAdd the ability to iterate over the digit of all primitive integer types. Also exposes the trait so one can implement it oneself.
homepage
repositoryhttps://github.com/hbina/integer-iterator
max_upload_size
id283387
size6,371
Hanif Ariffin (hbina)

documentation

README

integer-iterator

Crates.io

Implement Iterator over primitive integer types in Rust. Also, this crate exposes the trait so one can implement it for any desired types.

Examples

    let mut positive = 1234u32.digits();
    assert_eq!(positive.next(), Some(4));
    assert_eq!(positive.next(), Some(3));
    assert_eq!(positive.next(), Some(2));
    assert_eq!(positive.next(), Some(1));

    let mut negative = (-1234i32).digits();
    assert_eq!(negative.next(), Some(4));
    assert_eq!(negative.next(), Some(3));
    assert_eq!(negative.next(), Some(2));
    assert_eq!(negative.next(), Some(1));
Commit count: 8

cargo fmt