-
Notifications
You must be signed in to change notification settings - Fork 335
Open
Description
Running this playground, it looks like you can't peek_nth
with an argument of usize::MAX
without panicking.
In a way, this makes sense cause peek_nth
gets you an item with index in 0..usize::MAX
, so getting the index usize::MAX
itself is out of bounds. However, if you peek_nth
past the end, this implementation returns None. I assume the implicit contract is that it should always return an option, and not panic.
It's pretty straighforward to special case usize::MAX
and just return None if its provided as an argument to peek_nth
. Otherwise, it can be kept as panicking and noted in the docs as an example.
Metadata
Metadata
Assignees
Labels
No labels