Crates.io | aabel-identifier-rs |
lib.rs | aabel-identifier-rs |
version | 0.1.2 |
source | src |
created_at | 2024-02-16 06:25:52.391409 |
updated_at | 2024-02-22 14:23:12.972042 |
description | A crate the defines identifier behavior, such comparing them, or generating sequences of identifiers. |
homepage | https://github.com/veminovici/aabel-identifier-rs |
repository | https://github.com/veminovici/aabel-identifier-rs |
max_upload_size | |
id | 1142129 |
size | 9,117 |
A Rust crate that defines some behavior related to identifiers, such:
Any type which implements the [Eq
] trait will automatically be an identifier.
use aabel_identifier_rs::*;
fn test_identifier(_id: impl Identifier) {
assert!(true);
}
let id = 10_u8;
test_identifier(id);
You can create an iterator which generates new idenfiers, given a starting point and a function which compute a new identifier value from a previous one.
use aabel_identifier_rs::*;
let id = 10_u8;
let mut iter = id.into_ids_iterator(|id| id + 1);
assert_eq!(iter.next(), Some(10));
assert_eq!(iter.next(), Some(11));
Code designed and written on the beautiful island of Saaremaa, Estonia.