Basically, i wanted to provide an “extension method” for Options that returns true if a provided option is some, so i can use it like this:
let res: Vec<Option<Nucleotide>> = element .to_uppercase() .chars() .map(Nucleotide::parse) .take_while(OptionExtensions::<Nucleotide>::is_some) <-- this is the desired usage .collect();
My first idea was to define a trait with default method, like this:
For this one, i get this error:
type annotations required: cannot resolve
I cannot put the type parameter to anywhere where it would work.
However, if i create a “dummy” struct and put the same method to the impl block, like this:
It starts working as intended.
the question is, why?