Hacker News new | past | comments | ask | show | jobs | submit login

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.




All 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: