ChrisBuchholz / accord

Data validation library for Rust
MIT License
78 stars 4 forks source link

Find a better way to use RangeInclusive #16

Open ChrisBuchholz opened 7 years ago

ChrisBuchholz commented 7 years ago

The patter used to implement length and range validators using RangeInclusive is ugly; especially the panic here: https://github.com/ChrisBuchholz/accord/blob/master/src/validators.rs#L74

Find a better way.

tcmal commented 6 years ago

The easiest way on nightly would be to use Range::contains() but that's experimental right now. It should probably default to false if the range is invalid.

tcmal commented 6 years ago

Inclusive range is in stable now (1.26.0) so we can use it, contains & stuff are basically just convenience.