Skip to main content

versal/
lib.rs

1#![no_std]
2
3use core::fmt::Debug;
4
5pub trait IntoResult: Sized {
6    fn into_ok<T>(self) -> Result<Self, T> {
7        Ok(self)
8    }
9    
10    fn into_err<T>(self) -> Result<T, Self> {
11        Err(self)
12    }
13}
14
15impl<T: Sized> IntoResult for T {}
16
17pub trait IntoOption: Sized {
18    fn into_some(self) -> Option<Self> {
19        Some(self)
20    }
21}
22
23impl<T: Sized> IntoOption for T {}
24
25pub trait AssertEq: Sized + Debug + PartialEq {
26    fn assert_eq(self, rhs: Self) {
27        assert_eq!(self, rhs);
28    }
29}
30
31impl<T: Sized + Debug + PartialEq> AssertEq for T {}