Skip to content

Commit

Permalink
Rollup merge of rust-lang#130087 - RalfJung:option-const-iter, r=work…
Browse files Browse the repository at this point in the history
…ingjubilee

remove 'const' from 'Option::iter'

This is kind of pointless to be a `const fn` since you can't do anything with the iterator. It is also the only `const fn iter*` in the entire standard library. It probably got constified when `~const` traits got added everywhere, and then was forgotten to be de-constified when that was undone.

The rest of the const_option feature seems like it can reasonably be stabilized, but this one IMO should not be stabilized, and it's not worth creating a new tracking issue.

Cc rust-lang#67441
  • Loading branch information
workingjubilee authored Sep 9, 2024
2 parents 6433a73 + f7d4da6 commit d7495b5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,8 @@ impl<T> Option<T> {
/// assert_eq!(x.iter().next(), None);
/// ```
#[inline]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn iter(&self) -> Iter<'_, T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter { inner: Item { opt: self.as_ref() } }
}

Expand Down

0 comments on commit d7495b5

Please sign in to comment.