Playing around with
@fasterthanlimeamos's facet (https://facet.rs/) and this maybe is kinda cool.
I re-implemented (parts of) Zig's std.MultiArrayList in Rust using facet and this example works.
Not even Miri complains.
If you have a fediverse account, you can quote this note from your own instance. Search https://hachyderm.io/users/jer/statuses/114473131381774611 on your instance and quote it. (Note that quoting is not supported in Mastodon.)
![#[derive(Facet)]
struct Pizza {
radius: i32,
toppings: Vec<Topping>,
}
#[derive(Facet)]
#[repr(u8)]
enum Topping {
Tomato,
Mozzarella,
Anchovies,
}
use Toppings::*;
let mut order = MultiArray::<Pizza>::new();
assert_eq!(0, order.len());
let margherita = Pizza {
radius: 12,
toppings: vec![Tomato, Mozzarella],
};
order.push(margherita);
let napoli = Pizza {
radius: 15,
toppings: vec![Tomato, Mozzarella, Anchovies],
};
order.push(napoli);
let pizza = order.pop();](https://media.hachyderm.io/media_attachments/files/114/473/131/163/695/830/original/bfa5d57f7b796a26.png)