option-filter:向Option添加一个.filter()方法

时间:2021-05-11 16:02:05
【文件属性】:
文件名称:option-filter:向Option添加一个.filter()方法
文件大小:3KB
文件格式:ZIP
更新时间:2021-05-11 16:02:05
Rust 选项过滤器 对于不提供此功能的较旧版本的Rust,此板条箱向Option添加.filter()方法。 注意: 已添加到的标准库中。 除非您需要支持旧版本的Rust,否则不需要使用此板条箱。 用法 要使用它,请将option-filter添加到您的Cargo.toml : [ dependencies ] option-filter = " 1.0 " 然后导入扩展特征: extern crate option_filter; use option_filter :: OptionFilterExt; 现在,您可以过滤您的Option ! let answer = Some ( 42 ); assert_eq! (answer. filter ( | x | * x == 42 ), Some ( 42 )); assert_eq! (answer. filter ( |
【文件预览】:
option-filter-master
----.gitignore(18B)
----README.md(967B)
----Cargo.toml(421B)
----lib.rs(2KB)
----.travis.yml(46B)

网友评论

相关文章