1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use super::*;

impl<T, E> From<Result<T, E>> for Validated<T, E> {
    #[inline]
    fn from(result: Result<T, E>) -> Self {
        match result {
            Ok(x) => Valid(x),
            Err(x) => Invalid(x),
        }
    }
}

impl<T, E> From<Validated<T, E>> for Result<T, E> {
    #[inline]
    fn from(validated: Validated<T, E>) -> Self {
        validated.into_result()
    }
}

if_std! {
    use crate::data::NEVec;

    impl<T, E> From<Validated<T, E>> for ValidatedNev<T, E> {
        #[inline]
        fn from(validated: Validated<T, E>) -> Self {
            validated.map_err(|e| NEVec::new(e))
        }
    }

    impl<T, E> From<Result<T, E>> for ValidatedNev<T, E> {
        #[inline]
        fn from(result: Result<T, E>) -> Self {
            match result {
                Ok(x) => Valid(x),
                Err(e) => Invalid(NEVec::new(e)),
            }
        }
    }
}