3 ms·
> Based on the pattern passed to the map function, the compiler figures out that the first call to array_chunks should chunk the data into an iterator of arrays
by zokier 6y ago
> Based on the pattern passed to the map function, the compiler figures out that the first call to array_chunks should chunk the data into an iterator of arrays with length 2, and in the second call it should be an iterator of arrays with length 3. It’s so cool!
Cool, but bit too implicit to my taste. But regardless, const generics are definitely one of the biggest features I've been looking forwards to (more so than e.g. async stuff that got all the hype), so glad to see stuff landing even with the restrictions.
- pcwalton 6y agoTo be clear, that pattern more or less falls out naturally from stuff that the typechecker already has to do to make const generics work in the type system. It's not so much a special feature as it is just the interaction of plain old type inference with const generics.