It seems there is no way of such one-line conversion using std
.
I do not like this kind of verbosity:
match my_bool {
true => Ok(()),
false => Err(MyError::False),
}
I would like to use a one-liner, for example:
let my_bool = true;
let my_option = my_bool.to_option(MyObject{}); // true => MyObject{}, false => None
let my_result = my_bool.to_result(MyObject{}, MyError{}); // true => MyObject{}, false => MyError{}
What is the shortest piece of code for doing that?