about summary refs log tree commit diff
path: root/library/core/src/iter/range.rs
AgeCommit message (Collapse)AuthorLines
2025-06-20Add diagnostic items for ClippySamuel Tardieu-0/+1
2024-11-21distinguish overflow and unimplemented in Step::steps_betweenmichirakara-62/+66
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-04-16Remove uneeded clones now that TrustedStep implies CopyArthur Carcano-8/+8
This is a follow up to 11fa1764ee4819aa674ca861c5e9a8fafd7a59e6
2024-03-25Import the 2021 prelude in the core crateDaniel Paoliello-1/+0
2024-03-14Rollup merge of #122461 - the8472:fix-step-forward-unchecked, r=AmanieuMatthias Krüger-2/+28
fix unsoundness in Step::forward_unchecked for signed integers Fixes #122420 ```rust pub fn foo(a: i8, b: u8) -> i8 { unsafe { a.checked_add_unsigned(b).unwrap_unchecked() } } ``` still compiles down to a single arithmetic instruction ([godbolt](https://rust.godbolt.org/z/qsd3xYWfE)). But we may be losing some loop optimizations if llvm can no longer easily derive that it's a finite counted loop from the no-wrapping flags.
2024-03-14fix unsoundness in Step::forward_unchecked for signed integersThe 8472-2/+28
2024-03-13Improve Step docsChristopher Durham-8/+7
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-4/+4
2024-02-15Use generic `NonZero` internally.Markus Reiter-13/+13
2023-09-17Auto merge of #113748 - clarfonthey:ip-step, r=dtolnaybors-1/+66
impl Step for IP addresses ACP: rust-lang/libs-team#235 Note: since this is insta-stable, it requires an FCP. Separating out from the bit operations PR since it feels logically disjoint, and so their FCPs can be separate.
2023-09-16Specialize count for range iteratorsltdk-0/+20
2023-09-16impl Step for IP addressesltdk-1/+66
2023-08-14Implement Step for AsciiCharltdk-1/+44
2023-05-29Make `TrustedStep` require `Copy`Scott McMurray-12/+13
All the implementations of the trait already are `Copy`, and this seems to be enough to simplify the implementations enough to make the MIR inliner willing to inline basics like `Range::next`.
2023-04-28Make sure that signatures aren't accidental refinementsMichael Goulet-4/+16
2023-04-08Revert "Make the `Step` implementations const."Deadbeef-14/+6
This reverts commit 7bc67ef6e02d69023c6fb04c2258beab54ac22b8.
2023-04-08Revert "Mark DoubleEndedIterator as #[const_trait] using ↵Deadbeef-8/+4
rustc_do_not_const_check, implement const Iterator and DoubleEndedIterator for Range." This reverts commit 8a9d6bf4fd540b2a2882193cbd6232b86e5dcd7e.
2023-03-27replace advance_by returning usize with Result<(), NonZeroUsize>The 8472-12/+13
2023-03-27Change advance(_back)_by to return `usize` instead of `Result<(), usize>`The 8472-12/+12
A successful advance is now signalled by returning `0` and other values now represent the remaining number of steps that couldn't be advanced as opposed to the amount of steps that have been advanced during a partial advance_by. This simplifies adapters a bit, replacing some `match`/`if` with arithmetic. Whether this is beneficial overall depends on whether `advance_by` is mostly used as a building-block for other iterator methods and adapters or whether we also see uses by users where `Result` might be more useful.
2023-03-18Mark DoubleEndedIterator as #[const_trait] using rustc_do_not_const_check, ↵onestacked-4/+8
implement const Iterator and DoubleEndedIterator for Range.
2023-03-17Make the `Step` implementations const.onestacked-6/+14
2023-02-12Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcmbors-1/+0
Use associated items of `char` instead of freestanding items in `core::char` The associated functions and constants on `char` have been stable since 1.52 and the freestanding items have soft-deprecated since 1.62 (https://github.com/rust-lang/rust/pull/95566). This PR ~~marks them as "deprecated in future", similar to the integer and floating point modules (`core::{i32, f32}` etc)~~ replaces all uses of `core::char::*` with `char::*` to prepare for future deprecation of `core::char::*`.
2023-01-14Remove various double spaces in source comments.André Vennberg-1/+1
2023-01-14Use associated items of `char` instead of freestanding items in `core::char`Lukas Markeffsky-1/+0
2022-09-26Use a macro to not have to copy-paste `ConstFnMutClosure::new(&mut fold, ↵Scott McMurray-26/+2
NeverShortCircuit::wrap_mut_2_imp)).0` everywhere Also use that macro to replace a bunch of places that had custom closure-wrappers.
2022-05-08Warn on unused doc(hidden) on trait impl itemsLeón Orell Valerian Liehr-1/+0
2021-12-14Fix a bunch of typosFrank Steffahn-2/+2
2021-09-30implement advance_(back_)_by on more iteratorsThe8472-0/+79
2021-09-28Optimize is_sorted for Range and RangeInclusiveMatt Brubeck-0/+10
The `Step` trait guarantees that `Range<impl Step>` yields items in sorted order. We can override the `Iterator::is_sorted` method based on this guarantee, as we already do for `Iterator::min` and `max`.
2021-07-29Fix may not to appropriate might not or must notAli Malik-1/+1
2021-07-28Change __iterator_get_unchecked to work with TrustedRandomAccessNoCoerceFrank Steffahn-1/+1
2021-07-28Add TrustedRandomAccessNoCoerce supertrait without requirements or ↵Frank Steffahn-2/+8
guarantees about subtype coercions Update all the TrustedRandomAccess impls to also implement the new supertrait
2021-07-14Correct invariant documentation for `steps_between`David Thompson-1/+1
Given that the previous example involves stepping forward from A to B, the equivalent example on this line would make most sense as stepping backward from B to A.
2021-06-16Add doc(hidden) to all __iterator_get_uncheckedJacob Hoffman-Andrews-0/+1
This method on the Iterator trait is doc(hidden), and about half of implementations were doc(hidden). This adds the attribute to the remaining implementations.
2021-05-26Unify feature flags as `step_trait`Jacob Pratt-6/+0
While stdlib implementations of the unchecked methods require unchecked math, there is no reason to gate it behind this for external users. The reasoning for a separate `step_trait_ext` feature is unclear, and as such has been merged as well.
2021-05-26Specialize implementationsJacob Pratt-105/+355
Implementations in stdlib are now optimized as they were before.
2021-05-26Make Range implementation safeJacob Pratt-29/+22
2021-05-26Limit `TrustedLen` impls to core typesJacob Pratt-6/+21
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-2/+2
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-09Fix `Step` feature flag, make tidy lint more useful to find things like thisltdk-2/+2
2021-05-06Perf Experiment: Wait, what if I just skip the trait aliasScott McMurray-3/+3
2021-05-06Bootstrapping preparation for the libraryScott McMurray-3/+3
Since just `ops::Try` will need to change meaning.
2021-03-21implement TrustedRandomAccess for Ranges over int typesThe8472-1/+42
2021-02-14Use `#[rustc_inherit_overflow_checks]` instead of Add::add etc.Mara Bos-3/+5
2021-01-23Allow libcore to be built with MIR inliningoli-0/+2
Inlining caused new lints to get emitted, so we silence those lints now that we actually can.
2021-01-07Fix typo in Step traitChristopher Durham-1/+1
2020-10-12Use `try{}` in `try_fold` to decouple library from `Try` detailsScott McMurray-4/+4
2020-07-27mv std libs to library/mark-0/+861