#[derive(Debug, Clone, Copy)]
pub struct Preset<P: Copy + 'static> {
pub name: &'static str,
pub blurb: &'static str,
pub params: P,
}
pub fn find<P: Copy>(table: &'static [Preset<P>], name: &str) -> Option<P> {
table
.iter()
.find(|p| p.name.eq_ignore_ascii_case(name))
.map(|p| p.params)
}
pub fn names<P: Copy>(table: &'static [Preset<P>]) -> String {
table.iter().map(|p| p.name).collect::<Vec<_>>().join(", ")
}
pub fn list<P: Copy>(table: &'static [Preset<P>]) -> String {
let mut s = String::new();
for p in table {
s.push_str(&format!(" {:<10} {}\n", p.name, p.blurb));
}
s
}