-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating invalid InclusiveInterval s #53
Comments
//only return valid range_bounds
return CutResult {
before_cut: result.before_cut.filter(|x| is_valid_range(*x)),
inside_cut: result.inside_cut.filter(|x| is_valid_range(*x)),
after_cut: result.after_cut.filter(|x| is_valid_range(*x)),
}; In the implementation I sometimes create invalid range and then filter them out at the end as is makes some of the logic simpler but I would be fine with creating an |
Hmm, I forgot but when going to implement this I remembered that if we ensure validity upon creation of a |
Hmm I think it would still be an acceptable tradeoff as I can still use the |
Another caveat discovered upon implementation is that the panics on all the methods will still be necessary as on a custom range type the user can still create an invalid range. But I can continue the invariant constructors way on the |
This crate requires
InclusiveRange
s to be valid when passing them to any of the functions, otherwise a panic will happenWould it make sense to verify that in the constructor of
InclusiveInterval
? Then the implementation ofInclusiveRange
forInclusiveInterval
could haveis_valid
be a no-op, and errors might be caught slightly sooner.The text was updated successfully, but these errors were encountered: