3 releases
0.1.2 | Jul 27, 2023 |
---|---|
0.1.1 | Jul 27, 2023 |
0.1.0 | Jul 27, 2023 |
#2769 in Rust patterns
4KB
bool-mappings
Useful extensions to convert bool
to other Rust types.
At the moment there are two extensions:
.true_or()
.false_or()
Examples
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)
}
License: MIT
lib.rs
:
Useful extensions to convert bool
to other Rust types.
At the moment there are two extensions:
.true_or()
.false_or()
Examples
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)
}