tailcall_valid/
lib.rs

1mod append;
2mod cause;
3mod valid;
4
5pub use cause::*;
6pub use valid::*;
7
8/// Moral equivalent of TryFrom for validation purposes
9pub trait ValidateFrom<T>: Sized {
10    type Error;
11    type Trace;
12    fn validate_from(a: T) -> Valid<Self, Self::Error, Self::Trace>;
13}
14
15/// Moral equivalent of TryInto for validation purposes
16pub trait ValidateInto<T> {
17    type Error;
18    type Trace;
19    fn validate_into(self) -> Valid<T, Self::Error, Self::Trace>;
20}
21
22/// A blanket implementation for ValidateInto
23impl<S, T: ValidateFrom<S>> ValidateInto<T> for S {
24    type Error = T::Error;
25    type Trace = T::Trace;
26    fn validate_into(self) -> Valid<T, Self::Error, Self::Trace> {
27        T::validate_from(self)
28    }
29}