Crates.io | integer-iterator |
lib.rs | integer-iterator |
version | 0.3.0 |
source | src |
created_at | 2020-09-01 12:37:14.396762 |
updated_at | 2022-02-27 09:25:45.387823 |
description | Add the ability to iterate over the digit of all primitive integer types. Also exposes the trait so one can implement it oneself. |
homepage | |
repository | https://github.com/hbina/integer-iterator |
max_upload_size | |
id | 283387 |
size | 6,371 |
Implement Iterator over primitive integer types in Rust. Also, this crate exposes the trait so one can implement it for any desired types.
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));