| Crates.io | mdnt-groups-support |
| lib.rs | mdnt-groups-support |
| version | 0.2.15 |
| created_at | 2025-11-12 14:36:13.7+00 |
| updated_at | 2026-01-21 18:24:33.287073+00 |
| description | Support traits for the `picus::group` macro |
| homepage | |
| repository | https://github.com/Veridise/midnight-extractor |
| max_upload_size | |
| id | 1929453 |
| size | 17,422 |
Support traits for the picus::group macro.
This crate defines the DecomposeIn trait. This trait enables decomposing a complex type into an iterator of simple types.
It is meant to be used with something like halo2_proofs::circuit::Cell but the trait is parametric.
use mdnt_groups_support::DecomposeIn;
#[derive(Debug,Copy,Clone,Eq,PartialEq)]
struct Cell(usize);
// The base type needs to implement the trait
impl DecomposeIn<Cell> for Cell {
fn cells(&self) -> impl IntoIterator<Item = Cell> {
std::iter::once(*self)
}
}
struct A {
cells: [Cell; 2],
}
impl DecomposeIn<Cell> for A {
fn cells(&self) -> impl IntoIterator<Item = Cell> {
// Some standard types come with implementations.
self.cells.cells()
}
}
struct B {
a: A,
cell: Cell
}
impl DecomposeIn<Cell> for B {
fn cells(&self) -> impl IntoIterator<Item = Cell> {
self.a.cells().into_iter().chain([self.cell])
}
}
let b = B {
a: A {
cells: [Cell(2), Cell(8)]
},
cell: Cell(15)
};
let cells = b.cells().into_iter().collect::<Vec<_>>();
let flat = vec![Cell(2), Cell(8), Cell(15)];
assert_eq!(cells, flat);