Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove iter::Empty hack #103945

Merged
merged 1 commit into from Dec 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions library/core/src/iter/sources/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@ pub const fn empty<T>() -> Empty<T> {
Empty(marker::PhantomData)
}

// Newtype for use in `PhantomData` to avoid
// > error: const-stable function cannot use `#[feature(const_fn_fn_ptr_basics)]`
// in `const fn empty<T>()` above.
struct FnReturning<T>(fn() -> T);

/// An iterator that yields nothing.
///
/// This `struct` is created by the [`empty()`] function. See its documentation for more.
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "iter_empty", since = "1.2.0")]
pub struct Empty<T>(marker::PhantomData<FnReturning<T>>);
pub struct Empty<T>(marker::PhantomData<fn() -> T>);

#[stable(feature = "core_impl_debug", since = "1.9.0")]
impl<T> fmt::Debug for Empty<T> {
Expand Down