3 ms·
In this example: fn collect<B: FromIterator<Self::Item>>(self) -> B where Self:Sized; I thought this was universal, not existential like the podcast claim
by eslaught 8y ago
In this example:
fn collect<B: FromIterator<Self::Item>>(self) -> B where Self:Sized;
I thought this was universal, not existential like the podcast claims. It would be existential if you instead wrote:
fn collect(self) -> impl FromIterator<Self::Item> where Self:Sized;
The latter is what got added in 1.26, whereas the former was already available before that.
And really, you wouldn't want to use the latter in this case because the user wants to choose the type that's being generated (this is not a case where you want the callee to choose the type). So the second signature wouldn't make a whole lot of sense even if this API had been stabilized post-1.26.
- chriskrycho 8y agoI may have gotten that wrong! Had a lot of things in flight for this episode and the universal/existential discussion was a late addition from before I split it into this and the upcoming episode focused on object safety, dynamic-vs.-static dispatch, and `impl Trait`.