diff --git a/doc/toolchain_limitations.md b/doc/toolchain_limitations.md index a1657d75ee..b8c100cd07 100644 --- a/doc/toolchain_limitations.md +++ b/doc/toolchain_limitations.md @@ -106,7 +106,7 @@ type Alias = Struct<{::N}>; ### `[tag:const_for]` `for` loops are unusable in `const fn` -Technically it's available under the compiler feature `const_for`, but the lack of essential trait implementations (e.g., `[ref:range_const_iterator]`, `[ref:const_slice_iter]`) and above all the inability of implementing `const Iterator` (`[ref:iterator_const_default]`) make it unusable. +Technically it's available under the compiler feature `const_for`, but the lack of essential trait implementations (e.g., `[ref:range_const_iterator]`, `[ref:const_slice_iter]`) makes it unusable in many cases. ### `[tag:const_static_item_ref]` `const`s and `const fn`s can't refer to `static`s @@ -449,25 +449,6 @@ const _: () = assert!(matches!((2..4).next(), Some(2))); ``` -### `[tag:iterator_const_default]` `Iterator` lack `#[const_trait]` - -```rust,compile_fail -#![feature(const_trait_impl)] -#![feature(const_mut_refs)] - -struct MyIterator; - -// error: const `impl` for trait `Iterator` which is not marked with `#[const_trait]` -impl const Iterator for MyIterator { - type Item = u32; - - fn next(&mut self) -> Option { - Some(42) - } -} -``` - - ### `[tag:const_assert_eq]` `assert_eq!` and similar macros are unusable in `const fn` ```rust,compile_fail,E0015 diff --git a/src/r3_core/src/bind/sorter.rs b/src/r3_core/src/bind/sorter.rs index 3535d4b008..c48ab6a093 100644 --- a/src/r3_core/src/bind/sorter.rs +++ b/src/r3_core/src/bind/sorter.rs @@ -318,7 +318,7 @@ pub(super) const fn sort_bindings( End, } - impl const MyIterator for VertexIter<'_> { + impl const Iterator for VertexIter<'_> { type Item = Vertex; fn next(&mut self) -> Option { @@ -369,7 +369,7 @@ pub(super) const fn sort_bindings( End, } - impl const MyIterator for SuccessorIter<'_, Callback> + impl const Iterator for SuccessorIter<'_, Callback> where Callback: ~const SorterCallback, { @@ -533,23 +533,14 @@ pub(super) const fn sort_bindings( // Helper traits // -------------------------------------------------------------------------- -// `const Iterator` is currently very hard to implement -// [ref:iterator_const_default] -/// An [`Iterator`][] usable in `const fn`. -#[const_trait] -trait MyIterator { - type Item; - fn next(&mut self) -> Option; -} - #[const_trait] trait GraphAccess { - type VertexIter<'a>: ~const MyIterator + ~const Destruct + 'a + type VertexIter<'a>: ~const Iterator + ~const Destruct + 'a where Self: 'a; fn vertices(&self) -> Self::VertexIter<'_>; - type SuccessorIter<'a>: ~const MyIterator + ~const Destruct + 'a + type SuccessorIter<'a>: ~const Iterator + ~const Destruct + 'a where Self: 'a; fn successors(&self, v: &VertexRef) -> Self::SuccessorIter<'_>;