Crates.io | parametrized |
lib.rs | parametrized |
version | 0.1.5 |
source | src |
created_at | 2024-09-20 10:54:47.693908 |
updated_at | 2024-10-14 08:41:58.295592 |
description | Supply useful iterating methods for user-defined types which are parametrized by type parameters |
homepage | |
repository | https://github.com/yasuo-ozu/parametrized |
max_upload_size | |
id | 1381122 |
size | 39,226 |
This Rust library provides a procedural macro attribute #[parametrized]
that automatically implements methods like [Parametrized::param_iter()
], [ParametrizedIntoIter::param_into_iter()
], [ParametrizedIterMut::param_iter_mut()
], and [ParametrizedMap::param_map()
] for user-defined struct and enum types. The primary purpose of the library is to enable seamless traversal and transformation of complex data structures containing various nested collection types.
The parametrized library is particularly well-suited for handling complex data structures commonly found in compiler development and systems programming, such as Abstract Syntax Trees (ASTs) and Instruction Set Architectures (ISAs). These data structures often involve deeply nested collections and varying node types, making manual implementation of methods like iter, iter_mut, and map both tedious and error-prone.
# use parametrized::*;
# use std::collections::BTreeSet;
# #[allow(unused)]
#[parametrized(default, into_iter, map)]
enum Instruction<Operand: Ord> {
BinaryOp {
_op: String,
_src: Operand,
_dest: BTreeSet<Operand>,
},
LoadStore {
_op: String,
_address: Vec<(Operand, bool)>,
_value: Operand,
},
Branch {
_condition: String,
_target: String,
},
}