我可以有一个在 Rust 中不被类型化为闭包的匿名函数吗?
Can I have an anonymous function that isn't typed as a closure in Rust?
我使用的是 1.6.0(稳定版),但任何 future/nightly 功能都可以 watch/track 实现,这也很酷。
理论上我想要什么(为简洁起见进行了简化):
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 的"anonymous function" 特性。
也就是说,您可以稍微减少您所拥有的冗余:
let a: fn(_) -> _ = { fn anon(_: &Mask) -> bool { true }; anon };
我使用的是 1.6.0(稳定版),但任何 future/nightly 功能都可以 watch/track 实现,这也很酷。
理论上我想要什么(为简洁起见进行了简化):
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 的"anonymous function" 特性。
也就是说,您可以稍微减少您所拥有的冗余:
let a: fn(_) -> _ = { fn anon(_: &Mask) -> bool { true }; anon };