milkey-mouse / planets

A space game.
GNU General Public License v3.0
3 stars 1 forks source link

lib w/ proc_macro #derive(Iter) on structs with fields of uniform type #28

Open todo[bot] opened 5 years ago

todo[bot] commented 5 years ago

https://github.com/milkey-mouse/planets/blob/41c1b8245f1dbcaa17665201bf995ee50559c7d4/src/render/queues.rs#L11-L16


This issue was generated by todo based on a // TODO: comment in 41c1b8245f1dbcaa17665201bf995ee50559c7d4.
milkey-mouse commented 5 years ago

This lib should also provide a cartesian_product function (or macro) over structs. For example, that would turn this:

&[
    Format { channels: 2, sample_rate: 44100, data_type: I16 },
    Format { channels: 2, sample_rate: 44100, data_type: U16 },
    Format { channels: 2, sample_rate: 44100, data_type: F32 },
    Format { channels: 2, sample_rate: 48000, data_type: I16 },
    Format { channels: 2, sample_rate: 48000, data_type: U16 },
    Format { channels: 2, sample_rate: 48000, data_type: F32 },
    Format { channels: 1, sample_rate: 44100, data_type: I16 },
    Format { channels: 1, sample_rate: 44100, data_type: U16 },
    Format { channels: 1, sample_rate: 44100, data_type: F32 },
    Format { channels: 1, sample_rate: 48000, data_type: I16 },
    Format { channels: 1, sample_rate: 48000, data_type: U16 },
    Format { channels: 1, sample_rate: 48000, data_type: F32 },
].iter()

into this:

Format::cartesian_product((1...2).rev(), &[44100, 48000], &[I16, U16, F32])

The defined order is important here (unlike in actual sets). I'd think the last argument would be the "least significant," like the list example above.