|
|
|
|
|
by burntsushi
1221 days ago
|
|
> Well, your example is not a generic closure, since inside `adder`, you already have a generic type `T`; it's introduced by the `fn` keyword. If we try to do the same for a closure, we would face a type error. This issue has been discussed on SO [1]. Of course it's generic. If you were to write the type out for the closure, it would be generic over 'T'. (Whether that type ever actually gets written out that way or not is a different matter.) As far as I can tell, what you're saying is that Rust doesn't support higher-rank polymorphism. Which is true (for types, but not for lifetimes). But that's not the same as "generics don't work with closures." > I haven't claimed that closures are not working You've said: > Closures in Rust are fundamentally broken. (which was completely unqualified and not to a "very limited set of circumstances") and (emphasis mine) > But I can basically demonstrate other language features that are not working with closures, such as generics |
|