home ~ projects ~ socials

Get Unique Values From A Vec In Rust

// TODO: Look at itertools and something like this
// which needs to be cut down to make a better example

pub fn make_template_list(r#type: &str, kind: &str, bounds: &str, template: &str) -> Vec<String> {
    let templates = vec![
        format!("sections/{}/{}/{}/{}.neoj", r#type, kind, bounds, template),
        format!("sections/{}/{}/{}/default.neoj", r#type, kind, bounds),
        format!("sections/{}/generic/{}/default.neoj", r#type, bounds),
    ];
    templates.into_iter().unique().collect()
}
-- end of line --

References