我使用的是 1.6.0(稳定版),但任何启用此功能或我可以观看/跟踪的 future /夜间功能也很酷。
理论上我想要什么(为简洁起见进行了简化):
let a:fn(&lib_plotMote::mask::Mask) -> bool = {fn(_)->true};
我得到的最接近的:
let a:fn(&lib_plotMote::mask::Mask) -> bool = { fn anon(_:&Mask)->bool{true}; anon };
最佳答案
没有。
闭包是 Rust 的“匿名函数”特性。
也就是说,您可以稍微减少您所拥有的冗余:
let a: fn(_) -> _ = { fn anon(_: &Mask) -> bool { true }; anon };
关于function - 我可以有一个在 Rust 中不被类型化为闭包的匿名函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35388729/