3 个版本
| 0.1.2 | 2023 年 7 月 27 日 |
|---|---|
| 0.1.1 | 2023 年 7 月 27 日 |
| 0.1.0 | 2023 年 7 月 27 日 |
#2769 在 Rust 模式
4KB
bool-mappings
将 bool 转换为其他 Rust 类型的有用扩展。
目前有两个扩展
.true_or().false_or()
示例
use bool_mappings::BoolMappings;
struct MyError;
// Turn a bool into a Result
fn some_fn() -> Result<(), MyError> {
true.true_or(MyError)
}
fn some_other_fn() -> Result<(), MyError> {
true.false_or(MyError)
}
许可证:MIT
lib.rs:
将 bool 转换为其他 Rust 类型的有用扩展。
目前有两个扩展
.true_or().false_or()
示例
use bool_mappings::BoolMappings;
struct MyError;
// Turn a bool into a Result
fn some_fn() -> Result<(), MyError> {
true.true_or(MyError)
}
fn some_other_fn() -> Result<(), MyError> {
true.false_or(MyError)
}