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

If you try to enforce start <= end you get a fallible range constructor which is a usability nightmare, which is why it's not enforced. It has nothing to do with `Range` being generic.

I mean consider:

`slice.get(start..end)`

against:

`(start..end).and_then(|range| slice.get(range))`




I would even say that it is optimized for the following

  slice[start.end]
particularly because `[]` indexing is already a panicky operation.


Sure, get is like [] but without panic.

I.e. slice.get(5..0) == None




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: