use mixed_array::mixed_array; use std::cmp::Ordering; // define a struct with a generic so the generated types are different #[derive(Clone, Debug)] struct Item { id: u32, #[allow(dead_code)] value: T, } impl Eq for Item {} //implement ordering for our item for any T impl PartialEq> for Item { fn eq(&self, other: &Item) -> bool { self.id == other.id } } impl PartialOrd> for Item { fn partial_cmp(&self, other: &Item) -> Option { self.id.partial_cmp(&other.id) } } impl Ord for Item { fn cmp(&self, other: &Self) -> Ordering { self.id.cmp(&other.id) } } fn main() { //can now create an array of different types let items = mixed_array![ Item::<&str> { id: 100, value: "blah", }, Item:: { id: 200, value: 123, }, Item:: { id: 300, value: 9.3, }, ]; dbg!(items.iter().min(), items.iter().max()); }