Sorry for these stupid questions, but I've got a hard time wrapping find the right ways in rust. I've got the following ultrasimple function:
struct Replacement<'a>(&'a str, &'a str);
fn parse_replacements<'a, T: Iterator<&'a str>>(replacements: Option<T>) -> Vec<Replacement<'a>>
{
if let Some(replacements_iter) = replacements {
let replacements_list: Vec<Replacement<'a>> = replacements_iter.collect().splitn(2, ':')
.map(|r| r.expect("invalid replacement value"))
.map(|r| Replacement(r.nth(0).unwrap(), r.nth(1).unwrap()))
.collect();
Some(replacements_list)
} else {
None
}
}
The compiler complains:
fn parse_replacements<'a, T: Iterator<&'a str>>(replacements: Option<T>) -> Vec<Replacement<'a>>
| ^^^^^^^^--------- help: remove these generics
| |
| expected 0 generic arguments
Why the heck ain't I allowed to say what my input type should be?