Expand description
A derive macro for implementing IntoIterator on newtype wrapper structs.
This crate provides the Iterable derive macro, which automatically implements
iteration traits for single-field tuple structs that wrap iterable collections.
§Example
use aptos_iterable_derive::Iterable;
use std::collections::HashMap;
#[derive(Iterable)]
struct Config(HashMap<String, String>);
let mut config = Config(HashMap::from([
("key".to_string(), "value".to_string()),
]));
// Use for-in loops directly
for (k, v) in &config {
println!("{k}: {v}");
}
// Or use iterator methods
for (k, v) in config.iter() {
println!("{k}: {v}");
}See Iterable for detailed documentation on the generated implementations.
Derive Macros§
- Iterable
- Derives
IntoIteratorimplementations and iterator methods for single-field tuple structs.