News for hackers. Stuff that matters.
Re:My least favorite Rust type by saurik on Monday September 21, 2020 @05:43PM (#24548799)
But why isn't it panicking on len()? How is 0 the right answer there?
Re:My least favorite Rust type by masklinn on Tuesday September 22, 2020 @01:29AM (#24551174)
Because that’s the length of the iterator? The range is empty, its exact size is 0.
Re:My least favorite Rust type by saurik on Wednesday September 23, 2020 @01:40PM (#24569735)
The range is invalid, not empty; someone had to do a validity check to return 0 to prevent it from returning -5 or trying to count up from 0 (depending on what it was willing to assume). A big point of the article is that a range of size 0 should always be iterable, but it somehow isn't, because it isn't actually of size 0.