Rollup merge of #130087 - RalfJung:option-const-iter, r=workingjubilee

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 https://github.com/rust-lang/rust/issues/67441
This commit is contained in:
Jubilee 2024-09-09 00:17:50 -07:00 committed by GitHub
commit 38520aed18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1338,9 +1338,8 @@ pub fn as_deref_mut(&mut self) -> Option<&mut T::Target>
/// 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() } }
}