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

feat: Add maybe_async_trait #334

Merged

Conversation

igamigo
Copy link
Contributor

@igamigo igamigo commented Oct 3, 2024

Adds maybe_async_trait which adds a way to use async_trait based on whether the async feature is turned on. The attribute needs to be set for the trait impl and definition blocks. The macro takes functions annotated with #[maybe_async], makes them async, and then sets #[async_trait].
One small consequence of this is that when you have code like this:

use winter_maybe_async::{maybe_async_trait, maybe_async}

#[maybe_async_trait]
pub trait Example {
    #[maybe_async]
    pub fn foo() { }
}

If you turn on the async feature, then maybe_async becomes an unused import (because maybe_async_trait essentially removes it from foo) which might affect clippy lints. One way to deal with this would be to import macros like this: use winter_maybe_async::*.

@facebook-github-bot
Copy link

Hi @igamigo!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@igamigo
Copy link
Contributor Author

igamigo commented Oct 3, 2024

Had to add various newlines and "summaries" (mostly placeholders, we likely need to replace with better text) to make the first paragraph shorter in doc comments because of failing clippy checks. For the same reason I also had to add a usage of div_ceil() instead of manually dividing.

Copy link
Collaborator

@irakliyk irakliyk left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you! I left a few comments inline - but these are for files not related to this PR. So, we can merge as is and then make updates separately.

examples/src/utils/rescue.rs Outdated Show resolved Hide resolved
crypto/src/hash/mds/mds_f64_8x8.rs Show resolved Hide resolved
air/src/proof/ood_frame.rs Outdated Show resolved Hide resolved
crypto/src/merkle/concurrent.rs Outdated Show resolved Hide resolved
utils/maybe_async/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@irakliyk irakliyk left a comment

Choose a reason for hiding this comment

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

All looks good! Thank you!

@irakliyk irakliyk merged commit e92e541 into facebook:next Oct 4, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants