Skip to content

Constify fold, reduce and last for iterator#151899

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Randl:const-iter-fold
Apr 6, 2026
Merged

Constify fold, reduce and last for iterator#151899
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Randl:const-iter-fold

Conversation

@Randl
Copy link
Copy Markdown
Contributor

@Randl Randl commented Jan 31, 2026

These functions only require the addition of [const] in appropriate places, so it feels like almost a trivial change. Most of the others require either consitifying additional traits, const closures, or both.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 31, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 31, 2026

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@tgross35
Copy link
Copy Markdown
Contributor

I think we should hold off here until at least next can be made const. Otherwise these are just bounds that aren't really useful now and may need to be changed down the line.

@Randl
Copy link
Copy Markdown
Contributor Author

Randl commented Jan 31, 2026

Not sure I follow? next isn't marked as non-const because it doesn't have a default implementation. The only implementation of const Iterator as for now is Option, which does have const next

#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
impl<A> const Iterator for Item<A> {
type Item = A;
#[inline]
fn next(&mut self) -> Option<A> {
self.opt.take()
}

@scottmcm

This comment was marked as resolved.

@rustbot rustbot assigned tgross35 and unassigned scottmcm Feb 1, 2026
@Randl
Copy link
Copy Markdown
Contributor Author

Randl commented Mar 13, 2026

ping @tgross35

@Randl
Copy link
Copy Markdown
Contributor Author

Randl commented Apr 5, 2026

@rustbot reroll

@rustbot rustbot assigned Mark-Simulacrum and unassigned tgross35 Apr 5, 2026
Copy link
Copy Markdown
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 6, 2026

📌 Commit 175d963 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 6, 2026
@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 6, 2026
Constify fold, reduce and last for iterator

These functions only require the addition of `[const]` in appropriate places, so it feels like almost a trivial change. Most of the others require either consitifying additional traits, const closures, or both.
rust-bors bot pushed a commit that referenced this pull request Apr 6, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #153440 (Various LTO cleanups)
 - #151899 (Constify fold, reduce and last for iterator)
 - #154561 (Suggest similar keyword when visibility is not followed by an item)
 - #154657 (Fix pattern assignment suggestions for uninitialized bindings)
 - #154717 (Fix ICE in unsafe binder discriminant helpers)
 - #154722 (fix(lints): Improve `ill_formed_attribute_input` with better help message)
 - #154777 (`#[cfg]`: suggest alternative `target_` name when the value does not match)
 - #154849 (Promote `char::is_case_ignorable` from perma-unstable to unstable)
 - #154850 (ast_validation: scalable vectors okay for rustdoc)
@rust-bors rust-bors bot merged commit e6ea1ae into rust-lang:main Apr 6, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 6, 2026
rust-timer added a commit that referenced this pull request Apr 6, 2026
Rollup merge of #151899 - Randl:const-iter-fold, r=oli-obk

Constify fold, reduce and last for iterator

These functions only require the addition of `[const]` in appropriate places, so it feels like almost a trivial change. Most of the others require either consitifying additional traits, const closures, or both.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Apr 7, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#153440 (Various LTO cleanups)
 - rust-lang/rust#151899 (Constify fold, reduce and last for iterator)
 - rust-lang/rust#154561 (Suggest similar keyword when visibility is not followed by an item)
 - rust-lang/rust#154657 (Fix pattern assignment suggestions for uninitialized bindings)
 - rust-lang/rust#154717 (Fix ICE in unsafe binder discriminant helpers)
 - rust-lang/rust#154722 (fix(lints): Improve `ill_formed_attribute_input` with better help message)
 - rust-lang/rust#154777 (`#[cfg]`: suggest alternative `target_` name when the value does not match)
 - rust-lang/rust#154849 (Promote `char::is_case_ignorable` from perma-unstable to unstable)
 - rust-lang/rust#154850 (ast_validation: scalable vectors okay for rustdoc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants