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

Make crate used in entry_point configurable #2068

Merged
merged 4 commits into from
Mar 26, 2024

Conversation

aumetra
Copy link
Member

@aumetra aumetra commented Mar 22, 2024

Replaces #1539

This PR makes the crate used in the expansion of the entry_point macro configurable.
But with actual error handling and a nice syntax.

Rename example:

#[entry_point(crate = "::my_crate::cw_std_reexport")]

It also rejects other attributes and syntaxes:

#[entry_point(other = "attribute")] // This is rejected
#[entry_point(::my_crate::cw_std_reexport)] // This is also rejected

TODO:

  • Tests

@aumetra aumetra requested review from uint and webmaster128 March 22, 2024 15:16
@aumetra
Copy link
Member Author

aumetra commented Mar 22, 2024

Whether the attribute is a string or a path can be changed pretty easily, so whatever fits better into the desired look

@aumetra aumetra marked this pull request as draft March 25, 2024 11:59
@aumetra aumetra marked this pull request as ready for review March 25, 2024 15:29
Copy link
Contributor

@uint uint left a comment

Choose a reason for hiding this comment

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

Small change, but very nicely done. LGTM, thanks!

@uint
Copy link
Contributor

uint commented Mar 25, 2024

Whether the attribute is a string or a path

AFAIK what you've done is idiomatic, so all good!

@aumetra aumetra merged commit 8a30e33 into main Mar 26, 2024
29 checks passed
@aumetra aumetra deleted the aw/cosmwasm-derive-configurable branch March 26, 2024 09:32
@webmaster128
Copy link
Member

#[entry_point(crate = "::my_crate::cw_std_reexport")]

Great stuff. But one naming thing: Aren't we setting the "module" there, not the "crate"?

@aumetra
Copy link
Member Author

aumetra commented Mar 26, 2024

But one naming thing: Aren't we setting the "module" there, not the "crate"?

Technically yes, you can set a module here and not only a crate. But I took the naming in this case from serde (https://serde.rs/container-attrs.html#crate) since it is probably most familiar to users

@webmaster128
Copy link
Member

okay, sure. Thanks for the clarification. I don't expect sub-module usages here anyways. From the very few users of the option, the majority puts in fact a different crate name in it.

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