4 releases
0.1.3 | Oct 10, 2020 |
---|---|
0.1.2 | Oct 10, 2020 |
0.1.1 | Oct 10, 2020 |
0.1.0 | Oct 10, 2020 |
#621 in Programming languages
Used in 2 crates
10KB
265 lines
as_bool
Provides an expanded notion of what is true and what is false.
Specifically with the AsBool trait, which an implementing type can use to express how it should be represented in a boolean context.
This crate also provides implementations of AsBool for Rust's builtin types and collections from the Standard Library. These implementations provide a truth table similar to the Groovy Truth implemented in the Groovy programming language. The truth table can be described as follow:
- booleans behave as expected.
- all non-zero numbers are
true
. 0
,0.0
,f32::NAN
,f64::NAN
, and'\0'
arefalse
.- non-empty strings are
true
. - empty strings are
false
. - non-empty collections are
true
. - empty collections are
false
. None
is alwaysfalse
.Err
is alwaysfalse
.Ok
andSome
are unwrapped and the contained item is evaluated according to the preceding rules.
Documentation: https://docs.rs/as_bool
lib.rs
:
as_bool provides an expanded notion of what is true and what is false.
Specifically with the AsBool trait, which an implementing type can use to express how it should be represented in a boolean context.
This crate also provides implementations of AsBool for Rust's builtin types and collections from the Standard Library. These implementations provide a truth table similar to the Groovy Truth implemented in the Groovy programming language. The truth table can be described as follow:
- booleans behave as expected.
- all non-zero numbers are
true
. 0
,0.0
,f32::NAN
,f64::NAN
, and'\0'
arefalse
.- non-empty strings are
true
. - empty strings are
false
. - non-empty collections are
true
. - empty collections are
false
. None
is alwaysfalse
.Err
is alwaysfalse
.Ok
andSome
are unwrapped and the contained item is evaluated according to the preceding rules.