Function unique

Source
pub fn unique<T: Hash + Eq>(
    it: impl IntoIterator<Item = T>,
) -> Result<impl Iterator<Item = Rc<T>>, Infallible>
Available on crate feature std only.
Expand description

Returns an iterator with all duplicates removed.

The sorting order is kept, no extra allocation is performed. However, to make it possible, the data is wrapped inside Rc.

#[derive(Template)]
#[template(ext = "html", source = "{% for elem in example|unique %}{{ elem }},{% endfor %}")]
struct Example<'a> {
    example: Vec<&'a str>,
}

assert_eq!(
    Example { example: vec!["a", "b", "a", "c"] }.to_string(),
    "a,b,c,"
);