home ~ socials ~ projects ~ rss

Get Unique Values From A Vec In Rust

October 2024
// 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
Share link:
https://www.alanwsmith.com/en/2o/1a/k9/1x/?get-unique-values-from-a-vec-in-rust