3 ms·
Style nits: this would be much better with an enum Return: enum Found { Empty, Before(T), After(T), Between(T, T), } ... and a range paramet
by mmastrac 2y ago
Style nits: this would be much better with an enum Return:
enum Found {
Empty,
Before(T),
After(T),
Between(T, T),
}
... and a range parameter instead of L and R.
And, TBH, this should probably just panic! on an invalid predicate rather than returning an error. Programming errors should panic.
- ChadNauseam 2y agoAll good points, thank you. A range parameter would be especially good because I think you could use RangeInclusive to emphasize that it’s an inclusive range which is not obvious from the type signature.