Skip to content

Constify fold, reduce and last for iterator#151899

Open
Randl wants to merge 1 commit intorust-lang:mainfrom
Randl:const-iter-fold
Open

Constify fold, reduce and last for iterator#151899
Randl wants to merge 1 commit intorust-lang:mainfrom
Randl:const-iter-fold

Conversation

@Randl
Copy link
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
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants