-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto implementation of Display. Add assertion macro `less!` Add default implementation for primitive types.
- Loading branch information
1 parent
0c56bcc
commit c6fc0ca
Showing
9 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[cfg(feature = "bench")] | ||
#[cfg(test)] | ||
mod bench; | ||
|
||
#[allow(clippy::module_inception)] mod validate; | ||
mod validate_impl; | ||
|
||
pub(crate) use validate::Valid; | ||
pub(crate) use validate::Validate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::error::Error; | ||
|
||
use crate::validate::Validate; | ||
|
||
/// Dummy impl Validate for primitive types | ||
macro_rules! impl_validate { | ||
($typ: ty) => { | ||
impl Validate for $typ { | ||
fn validate(&self) -> Result<(), Box<dyn Error>> { | ||
Ok(()) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
impl_validate!(bool); | ||
impl_validate!(usize); | ||
impl_validate!(isize); | ||
impl_validate!(u8); | ||
impl_validate!(u16); | ||
impl_validate!(u32); | ||
impl_validate!(u64); | ||
impl_validate!(i8); | ||
impl_validate!(i16); | ||
impl_validate!(i32); | ||
impl_validate!(i64); | ||
impl_validate!(&str); | ||
impl_validate!(String); |