What is the difference between a generic lifetime in the impl vs. in an associated function?

Maybe I'm misreading, but that sounds like a contradiction to me: this snippet is inferred like the former snippet of your OP. Every function input parameter with an elided lifetime gets its own fresh lifetime binding.

But that does make the first/former version consistent with this maximally elided version. (Which is why I'm confused/read a contradiction.) However the elision rules were chosen to cover the most common cases -- that doesn't mean a signature with more elision is always more idiomatic.

See also the meaning of '_ in an impl header (vs. function signature):

If the type's lifetime is not relevant, you can leave it off using '_ .

(It's relevant to an associated constructor function.)

3 Likes