gpt4 book ai didi

function - 我可以有一个在 Rust 中不被类型化为闭包的匿名函数吗?

转载 作者:行者123 更新时间:2023-11-29 08:30:08 26 4
gpt4 key购买 nike

我使用的是 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com