#![no_std]
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
pub trait ToTrue: Sized {
fn to_true<F, R>(&mut self, f: F) -> Option<R>
where F: FnOnce() -> R;
fn to_false<F, R>(&mut self, f: F) -> Option<R>
where F: FnOnce() -> R;
}
impl ToTrue for bool {
fn to_true<F, R>(&mut self, f: F) -> Option<R>
where F: FnOnce() -> R,
{
if *self {
None
} else {
*self = true;
Some(f())
}
}
fn to_false<F, R>(&mut self, f: F) -> Option<R>
where F: FnOnce() -> R,
{
if *self {
*self = false;
Some(f())
} else {
None
}
}
}