TwoVec: A Very Silly Container
Lets say you want to store two different types of objects in 1 container. Simple right? Just slap those puppies in a tuple and you're good to go:
let list: Vec<(u8, f32)> = vec![(255, 20.0), (10, 37.0)];But what if you wanted to include elements of two different types in arbitrary orders? Thankfully, there's sum types for that:
pub enum Val {
A(u8),
B(f32),
}
... {
let list = vec![Val::A(255), Val::B(20.0), Val::B(37.0), Val::A(10)];
}One small problem. That's wasteful.