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!: Implement support for generic params #17

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

DanikVitek
Copy link

@DanikVitek DanikVitek commented Jan 18, 2025

Also:

  • Improve error messages
  • Extendable type-safe rewrite of the macro expansion

Closes #16.

@DanikVitek DanikVitek changed the title WIP: Implementing support for generic params; Extendable type-safe rewrite of the macro expansion. Implement support for generic params; Extendable type-safe rewrite of the macro expansion. Jan 20, 2025
@DanikVitek DanikVitek marked this pull request as ready for review January 20, 2025 13:03
@DanikVitek
Copy link
Author

Hello, @scouten. Ready for review

@DanikVitek DanikVitek changed the title Implement support for generic params; Extendable type-safe rewrite of the macro expansion. Implement support for generic params; Improve error messages. Extendable type-safe rewrite of the macro expansion. Jan 20, 2025
@DanikVitek
Copy link
Author

DanikVitek commented Jan 20, 2025

Should be marked as "Closes #16"

Needs to be new major, because async_signature now requires to explicitly specify or not specify the return type
@DanikVitek
Copy link
Author

I need to add support for #[cfg_attr(..., async_generic)], so don not merge just yet

@DanikVitek
Copy link
Author

Or rather, attributes on async_signature

@DanikVitek
Copy link
Author

Battle-testing the implementation on borsh-rs

@scouten
Copy link
Owner

scouten commented Jan 21, 2025

@DanikVitek this looks very interesting. I'll want to make sure the CI runs pass before merging and also for you to add the #[cfg(...)] upgrades that you are planning.

Let me know how I can help.

Copy link
Owner

@scouten scouten left a comment

Choose a reason for hiding this comment

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

Great and welcome proposal! I look forward to the final draft as discussed in my initial comments.

@@ -1,6 +1,6 @@
[package]
name = "async-generic"
version = "1.1.2"
Copy link
Owner

Choose a reason for hiding this comment

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

Please remove this diff. This project uses release-plz (https://release-plz.dev/docs) to manage versioning and that infrastructure will automatically do the necessary updates at the time based on how the PR is labeled.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm also questioning whether this PR meets the criteria for bumping to a 2.0. Under the rules of semantic versioning, that should only happen if there's an incompatible API change to the library. I see changes you've made to the async_signature parameter of the macro, but do the break compatibility? If not, let's make this a 1.2.0 release (which would involve removing the ! from the PR title as I've amended it).

Copy link
Author

@DanikVitek DanikVitek Jan 21, 2025

Choose a reason for hiding this comment

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

as I've described in the description of the commit 6d1b01e, the changes are indeed breaking.
async_signature(a: B) means, that the async function does not have a return type, while previously this meta tag affected only the input arguments

…ersions, storing only respective kind of functions, and llow to specify custom trait bounds on async version
@DanikVitek DanikVitek requested a review from scouten January 21, 2025 23:35
@DanikVitek
Copy link
Author

I might also add the sync_signature meta tag for functions to allow annotating sync functions with attributes, unique to them. For example, doc comments should be somewhat different for sync and async functions

@DanikVitek
Copy link
Author

@DanikVitek this looks very interesting. I'll want to make sure the CI runs pass before merging and also for you to add the #[cfg(...)] upgrades that you are planning.

Let me know how I can help.

I need to add new features behind feature flags?

@scouten scouten changed the title Implement support for generic params; Improve error messages. Extendable type-safe rewrite of the macro expansion. feat!: Implement support for generic params Jan 22, 2025
@scouten
Copy link
Owner

scouten commented Jan 22, 2025

@DanikVitek no, I wasn't talking about Rust crate feature flags. What I was referring to was the Conventional Commits syntax, which is required in this project for all pull requests. I've updated the PR title to be compliant, but if this is not a breaking change, then we should remove the ! from the title.

@DanikVitek
Copy link
Author

Now that I think about it, what are the reasons anybody would want to change the return type of their async function relative to the sync function? The only real reason I can come up with is if they're using a custom Future implementation. But in that case, why would they use this crate, as the custom future requires to move the implementation elsewhere, or surround the whole function body with an async move {...} block?

@DanikVitek
Copy link
Author

DanikVitek commented Jan 22, 2025

What I was referring to was the Conventional Commits syntax

I'm sorry, then I'm not sure what you meant by me adding the #[cfg(...)] upgrades that I'm planning. Are you referring to the comment about #[cfg_attr(...)] support? If so, then I've already added, tested, and rejected the approach.
I've remade it so you just need to put the required annotations onto the async_signature, async_trait, or sync_trait. And now I'm thinking about also adding the sync_signature for this purpose.

@DanikVitek DanikVitek marked this pull request as draft January 22, 2025 11:20
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.

Generic dependent on sync/async
2 participants