| Crates.io | lattices_macro |
| lib.rs | lattices_macro |
| version | 0.5.10 |
| created_at | 2024-07-23 03:44:57.782858+00 |
| updated_at | 2025-07-30 22:27:19.671587+00 |
| description | Procedural macros for the `lattices` crate. |
| homepage | |
| repository | https://github.com/hydro-project/hydro |
| max_upload_size | |
| id | 1312359 |
| size | 53,006 |
#[derive(Lattice)] MacroA struct of multiple lattices can form a product lattice. The simplest case of this is the Pair
lattice, which is a product of two sub-lattices. For more than two lattices, and/or to improve
readability, users can create their own product lattice structs, where each field is a sub-lattice,
and use the #[derive(Lattice)] macro to automatically derive the lattice traits.
Derives Merge, PartialEq, PartialOrd, LatticeOrd, IsBot, IsTop, and LatticeFrom,
and therefore Lattice too. Alternatively, individual traits can be derived:
#[derive(Merge, LatticeOrd, IsBot, IsTop, LatticeFrom)]. Note that LatticeOrd also derives
PartialEq and PartialOrd.
Note that all fields must be lattice types. If any field cannot be a lattice type then the
where clauses prevent the trait impl from compiling.
These derive macros will create a second set of generics to allow conversion and merging between varying types. For example, given this struct:
#[derive(Lattice)]
struct MyLattice<KeySet, Epoch>
where
KeySet: Collection,
Epoch: Ord,
{
keys: SetUnion<KeySet>,
epoch: Max<Epoch>,
}
Will create derive macros impls in the form:
impl<KeySet, Epoch, KeySetOther, EpochOther>
Merge<MyLattice<KeySetOther, EpochOther>> for MyLattice<KeySet, Epoch>
where
KeySet: Collection,
Epoch: Ord,
KeySetOther: Collection,
EpochOther: Ord,
{
// ...
}