rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.38k stars 12.72k forks source link

Tracking Issue for `const` `Iterator` impls and related `const fn`s #92476

Open fee1-dead opened 2 years ago

fee1-dead commented 2 years ago

Feature gate: #![feature(const_iter)]

This is a tracking issue for const Iterator impls and related const fns.

Public API

// core::iter
impl<I: ~const Iterator + ?Sized> const Iterator for &mut I;
impl<I: Iterator> const IntoIterator for I;
impl<B, I: ~const Iterator, F> const Iterator for Map<I, F>
where
    F: ~const FnMut(I::Item) -> B + ~const Drop;

// core::option
impl<T> Option<T> {
    pub const fn iter_mut(&mut self) -> IterMut<'_, T>;
}

impl<T> const IntoIterator for Option<T>;
impl<'a, T> const IntoIterator for &'a Option<T>;
impl<'a, T> const IntoIterator for &'a mut Option<T>;
impl<'a, A> const Iterator for Iter<'a, A>;
impl<'a, A> const Iterator for IterMut<'a, A>;
impl<A> const Iterator for IntoIter<A>;

Steps / History

Unresolved Questions

Expyron commented 2 years ago

Does this issue also track const implementations of slice and str iterators and their related functions or would that be a separate tracking issue?

For example:

fee1-dead commented 2 years ago

@Expyron: those implementations have not been added yet. My plan is to land the smallest possible PR that simply makes it possible to work, and constify others in much smaller, finer grained PRs. Further work should use this tracking issue if related.

TiagoCavalcante commented 2 years ago

Any updates on this?

fee1-dead commented 2 years ago

@TiagoCavalcante: implementation has been stalled for more compiler related work to make this as easy to maintain as possible.

ImUrX commented 1 year ago

@fee1-dead could you update the linked PR to the new one?

rinarakaki commented 2 months ago

Is this affected by https://github.com/rust-lang/rust/pull/110393?