Re:C++ Coroutines Do Not Spark Joy
by wizzwizz4 on Monday November 01, 2021 @03:12PM
(#29071517)
That's how I used to write it in 2018, before I discovered the `impl` keyword. It's the obvious way of doing it. (Though I'd've used `Iterator` rather than `IntoIterator` because I came from Python. (Yes, I know `IntoIterator` is the version best matching Python's behaviour.))
[ Parent
| on HN ]
Note that impl is not exactly equivalent. If the type passed in is ambiguous, with an explicit template the caller can disambiguate, but with impl there's no template argument.
So sometimes you still want to use the "old" syntax in your public APIs, even when you could be using an impl trait