gextra/bool
Functions
pub fn lazy_map(
condition: Bool,
if_cb: fn() -> a,
else_cb: fn() -> a,
) -> a
Deprecated: Use stdlib bool.lazy_guard()
Map a boolean value to the result of one of two functions. The function corresponding to the boolean value will be called, and the other will not.
Example
let assert 1 = bool.lazy_map(True, fn() { 1 }, fn() { 2 })
let assert 2 = bool.lazy_map(False, fn() { 1 }, fn() { 2 })