Crate weak_true

Source
Expand description

Similar to the automatic implicit conversion to boolean values in weakly typed languages

typeimpl
floatself is not 0.0 / NaN
integerself != 0
reference / smart pointerinner value impl
raw pointer!self.is_null
Optionself.is_some
Resultself.is_ok
Pollself.is_ready
str / slice / array!self.is_empty
collections!self.is_empty
unitfalse
boolself
fn / tuple / chartrue

§Examples

use weak_true::WeakTrue;

assert!("c".weak_true());
assert!('c'.weak_true());
assert!('\0'.weak_true());
assert!([0].weak_true());
assert!((&0 as *const i32).weak_true());
assert!(Some(0).weak_true());

assert!(f64::NAN.weak_false());
assert!(0.0.weak_false());
assert!(0.weak_false());
assert!("".weak_false());
assert!([0; 0].weak_false());

Macros§

wif
if but use weak_true result value

Structs§

WeakBoolIter
Created from weak_true and weak_false method

Traits§

WeakBoolIterExtend
WeakTrue
Similar to the automatic implicit conversion to boolean values in weakly typed languages