3 ms·
Again noob question about syntax: > impl<'a> ProductService<'a> I understand why <'a> is here, but why repeated twice?
by EugeneOZ 11y ago
Again noob question about syntax:
> impl<'a> ProductService<'a>
I understand why <'a> is here, but why repeated twice?
- steveklabnik 11y agoThe first one defines the list of all parameters, and the second uses it. In short definitions like this, it seems redundant, but it's more obvious with a more complex example: impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap<K, V, S> where K: Eq + Hash + Borrow<Q>, Q: Eq + Hash, S: HashState Okay, maybe that's not obvious, I picked a really gross example on purpose. :) The first part says "we're generic over five things: 'a, K, Q, V, and S. And then each of those five things gets used various times in the rest of the definition.