It's quite annoying at the beginning that the errors you get make you believe that 'closure' is a type in itself, because the errors themselves quote the word as if it was some kind of type, but then you can't specify something like let f: closure = ....
Well, the closure has a type. Just you cannot declare it. That's why you do "impl Fn" instead. Because you know that whatever type the close is, it implements the "Fn" trait.
Do you have a different recommendation for how to display unnameable types in error messages? I'm sure the compiler team would consider any suggestions.
4 Comments
kubica@fedia.io · 3 pts · 333d
It's quite annoying at the beginning that the errors you get make you believe that 'closure' is a type in itself, because the errors themselves quote the word as if it was some kind of type, but then you can't specify something like
let f: closure = ....calcopiritus@lemmy.world · 8 pts · 333d
Well, the closure has a type. Just you cannot declare it. That's why you do "impl Fn" instead. Because you know that whatever type the close is, it implements the "Fn" trait.
BatmanAoD@programming.dev · 3 pts · 332d
Do you have a different recommendation for how to display unnameable types in error messages? I'm sure the compiler team would consider any suggestions.
tjunge@twit.social · 3 pts · 332d
@turbohz Very nice summary, thanks!