finchers_core/
option.rs

1use self::sealed::Sealed;
2
3/// A helper trait enforcing that the type is `Option`.
4pub trait IsOption: Sealed {
5    /// The type of inner value.
6    type Item;
7
8    /// Consume itself and get the value of `Option`.
9    fn into_option(self) -> Option<Self::Item>;
10}
11
12impl<T> IsOption for Option<T> {
13    type Item = T;
14
15    #[inline(always)]
16    fn into_option(self) -> Option<Self::Item> {
17        self
18    }
19}
20
21mod sealed {
22    pub trait Sealed {}
23
24    impl<T> Sealed for Option<T> {}
25}