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

Split the proc macro to dependency crate #31

Closed
idanarye opened this issue Jan 21, 2020 · 3 comments · Fixed by #93
Closed

Split the proc macro to dependency crate #31

idanarye opened this issue Jan 21, 2020 · 3 comments · Fixed by #93

Comments

@idanarye
Copy link
Owner

The TypedBuidler custom derive proc macro generates some helpers. In current master there are {BuilderType}_Optional and {BuilderType}_core, and #30 is adding some bottom types ({BuilderType}_Error_Missing_required_field_{field_name} and {BuilderType}_Error_Repeated_field_{field_name})

These things are weirdly mangled and repeated for every struct with a typed builder even though they are exactly the same - it would be better if we could just put them in the typed builder crate, with legal Rust names, and just reuse them. The problem is that proc macro crates are not allowed to export anything that's not a proc macro.

The solution: split the proc macro to a new crate - say typed-builder-procmacro - and have typed-builder re-export it. This is the common solution for this problem in Rust-2018 where macros can be imported/exported like regular symbols.

@idanarye
Copy link
Owner Author

Actually, I think I'll keep {BuilderType}_Error_Repeated_field_{field_name} - at least for now - because it gets into the build error. {BuilderType}_Error_Missing_required_field_{field_name} doesn't show in the error message so I'll replace it once I split the crate.

image

@mo8it
Copy link
Contributor

mo8it commented Jun 7, 2023

@idanarye May I do this?

@idanarye
Copy link
Owner Author

idanarye commented Jun 7, 2023

Sure

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 a pull request may close this issue.

2 participants