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

Apply alternate LinkedList suggested solution. #2805

Merged
merged 5 commits into from Sep 2, 2020

Conversation

mental32
Copy link
Sponsor Contributor

Motivation

Reference: #2790 (comment)

The current internal LinkedList had an implementation unsuitable for a const-fn constructor due to a generic constraint requiring feature(const_fn) which is nightly-only and we'd like to avoid that.

Applied here is a solution proposed by @hawkw in the referenced comment above that allows LinkedList::const_new to exist without the need of feature(const_fn)

Solution

The LinkedList definition expanded from a single generic parameter T to L, T and an unconstrained impl allowed LinkedList::const_new to be allowed by the compiler and now we have to explicitly specify the Link::Target in the second generic parameter T

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-maintenance Category: PRs that clean code up or issues documenting cleanup. M-sync Module: tokio/sync labels Aug 31, 2020
@Darksonn Darksonn requested a review from hawkw August 31, 2020 19:36
@mental32 mental32 force-pushed the mental/const-able-linked-list branch from 87a1756 to d73321f Compare September 1, 2020 08:08
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with making this change. The new code is definitely a bit uglier than it was previously, but I think we all expected that :) and it's worth it to make the const fn constructors work on stable.

I had a couple small suggestions.

tokio/src/util/linked_list.rs Outdated Show resolved Hide resolved
tokio/src/sync/notify.rs Outdated Show resolved Hide resolved
@mental32
Copy link
Sponsor Contributor Author

mental32 commented Sep 2, 2020

I've applied the suggested changes, I can't see anything else that needs doing here 😄

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great to me — @carllerche, did you want to sign off on it, or shall i just go ahead and ship it?

@carllerche carllerche merged commit c9f5bc2 into tokio-rs:master Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-maintenance Category: PRs that clean code up or issues documenting cleanup. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants