validit/validate_ext.rs
1//! Extension trait to ease the use of `Validate` trait.
2
3use crate::Valid;
4use crate::Validate;
5
6pub trait ValidateExt: Validate {
7 /// Return an always valid instance `Valid<Self>` that enables internal state validation.
8 fn valid(self) -> Valid<Self>
9 where Self: Sized;
10}
11
12impl<T: Validate> ValidateExt for T {
13 fn valid(self) -> Valid<Self>
14 where Self: Sized {
15 Valid::new(self)
16 }
17}