Mixed Array

Construct arrays of mixed types. Generic enums are created for up to 12 unique types. A macro to generate an array using the correct size macro is provided.

Usage

  1. Include in the Cargo.toml file: toml [dependencies] mixed_array = "0.1.0"

  2. Import and use the mixed_array macro to create an array of items ```rust use mixedarray::mixedarray; use std::cmp::Ordering;

// define a struct with a generic so the generated types are different as a demo

[derive(Clone, Debug)]

struct Item { id: u32, 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 partialcmp(&self, other: &Item) -> Option { self.id.partialcmp(&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.into_iter().min());

} ```

Alternatives