into-result 0.3.1

A simple convenience trait for converting something into a `Result` or `Option`
Documentation
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(all(feature = "command", not(feature = "std")))]
compile_error!("`command` feature requires `std`");

#[cfg(all(feature = "command", feature = "std"))]
pub mod command;

use core::{option::Option, result::Result};

pub trait IntoResult<T, E> {
    fn into_result(self) -> Result<T, E>;

    fn into_option(self) -> Option<T>
    where
        Self: Sized,
    {
        self.into_result().ok()
    }
}

impl IntoResult<(), ()> for bool {
    fn into_result(self) -> Result<(), ()> {
        if self {
            Ok(())
        } else {
            Err(())
        }
    }
}