Files
rust/src/libcore
Ralf Jung 93d45a01e7 Rollup merge of #72368 - CAD97:rangeto, r=dtolnay
Resolve overflow behavior for RangeFrom

This specifies a documented unspecified implementation detail of `RangeFrom` and makes it consistently implement the specified behavior.

Specifically, `(u8::MAX).next()` is defined to cause an overflow, and resolve that overflow in the same manner as the `Step::forward` implementation.

The inconsistency that has existed is `<RangeFrom as Iterator>::nth`. The existing behavior should be plain to see after #69659: the skipping part previously always panicked if it caused an overflow, but the final step (to set up the state for further iteration) has always been debug-checked.

The inconsistency, then, is that `RangeFrom::nth` does not implement the same behavior as the naive (and default) implementation of just calling `next` multiple times. This PR aligns `RangeFrom::nth` to have identical behavior to the naive implementation. It also lines up with the standard behavior of primitive math in Rust everywhere else in the language: debug checked overflow.

cc @Amanieu

---

Followup to #69659. Closes #25708 (by documenting the panic as intended).

The documentation wording is preliminary and can probably be improved.

This will probably need an FCP, as it changes observable stable behavior.
2020-05-30 13:45:02 +02:00
..
2020-04-06 22:44:51 +02:00
2020-04-25 09:25:33 -04:00
2020-05-22 10:55:01 +02:00
2020-04-23 23:05:37 +02:00
2020-05-23 14:00:55 +02:00
2020-05-26 11:59:23 +09:00
2020-04-25 09:25:33 -04:00
2020-05-22 15:29:47 +00:00
2020-05-12 16:54:29 +01:00
2019-11-26 23:02:11 -08:00
2019-12-22 17:42:47 -05:00
2020-04-25 09:25:33 -04:00
2020-04-23 11:06:46 -04:00
2020-05-13 21:13:35 +08:00
2020-02-23 23:59:39 -08:00
2019-11-26 23:02:11 -08:00
2019-11-26 23:02:11 -08:00