range_checker
range_checker is a derive-macro crate aimed to provide declarative bounds checking and filtering for structure.
Examples
use Check;
Features
range
Use #[range(...)] to detemine the range for named struct's field.
Multiple #[range(...)] will combined by ||, which allowed to config any range you need.
filter
Use #[filter(#closure)] to filter for named struct's field, #closure: |#type_of_field| -> bool.
Multiple #[filter(#closure)] will combined by &&.
#[filter(#closure)] will combined with #[range(...)] by &&.
fallback
Active with the
fn check_with_callback()
Use #[fallback(#closure|#lit)] to set fallback behavior for named struct's field, #closure: |#type_of_field| -> #type_of_field.
One field brokes it's range or filter with fallback attribute setted, fn check_with_fallback() will return Ok(_).
Check or CheckVervose
range_checker::Check will return Err(()) immediately any field broke it's range or filter.
range_checker::CheckVerbose will check all fields and return detail information like Err(Vec<Error>) or Ok(Vec<Error>) when all of broken fields has a fallback attribute.