You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why is the ... as ... part needed to evaluate property functions? #216
Curious, why do I need to remind the compiler that my fn (seed : usize, password : String) -> bool { ... } is a fn(usize, String) -> bool with the as token when I pass this function to quickcheck::quickcheck()?
As a workaround, I am declaring my properties as lambdas variables, explicitly typed to their signatures. But I would prefer not to have to do this.
Nobody would prefer to do this. I think this requirement was introduced here by making each fn item have its own distinct type: rust-lang/rust#19891
There is already an issue tracking this problem for quickcheck, and in particular, we would like to be ablw to use closures for property functions: #56
The quickcheck macro is meant to alleviate this annoyance in some cases.
Hi @BurntSushi -- I'm just a beginner with Rust but I'm struggling to understand what the benefit of that "unique type per fn item" PR was. We can see the downside of it is lots of extra as fn(...) -> ... annotations in heavily functional code, but there must have been some good reason to do it that outweighed the noise?
That PR was from 6 years ago. I don't have any context on it now. FWIW, I've only ever run into this problem with quickcheck specifically. I do not think it is endemic to "heavily functional" code.
Activity
BurntSushi commentedon Oct 28, 2018
Nobody would prefer to do this. I think this requirement was introduced here by making each fn item have its own distinct type: rust-lang/rust#19891
There is already an issue tracking this problem for quickcheck, and in particular, we would like to be ablw to use closures for property functions: #56
The quickcheck macro is meant to alleviate this annoyance in some cases.
DestyNova commentedon Feb 17, 2020
Hi @BurntSushi -- I'm just a beginner with Rust but I'm struggling to understand what the benefit of that "unique type per fn item" PR was. We can see the downside of it is lots of extra
as fn(...) -> ...annotations in heavily functional code, but there must have been some good reason to do it that outweighed the noise?BurntSushi commentedon Feb 17, 2020
That PR was from 6 years ago. I don't have any context on it now. FWIW, I've only ever run into this problem with quickcheck specifically. I do not think it is endemic to "heavily functional" code.