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

[WIP]Custom names for structs, enums & functions #108

Conversation

ronan-ditto
Copy link
Contributor

  • Builder::generate_with_definer has been splitted in subfunction for
    better readability
  • added type alias GenerationFunction
  • added NameConvention option on builder

@ronan-ditto ronan-ditto linked an issue May 17, 2022 that may be closed by this pull request
* Builder::generate_with_definer has been splitted in subfunction for
better readability
* added type alias GenerationFunction
* added NameConvention option on builder
@ronan-ditto ronan-ditto force-pushed the rd/customizable-naming-templates-eg-namespace-prefixing branch from d1a1ee7 to 8c0a706 Compare May 17, 2022 15:33
Copy link
Collaborator

@danielhenrymantilla danielhenrymantilla left a comment

Choose a reason for hiding this comment

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

Awesome 😍

}

fn guard(&self) -> String {
self.guard.unwrap_or(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.guard.unwrap_or(
self.guard.map_or_else(||

env::var("CARGO_PKG_NAME")
.unwrap()
.to_ascii_uppercase()
)).to_string()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
)).to_string()
), str::to_string)


fn guard(&self) -> String {
self.guard.unwrap_or(
&format!("__RUST_{}__",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
&format!("__RUST_{}__",
format!("__RUST_{}__",

Comment on lines +502 to +504
Default,
Suffix(String),
Prefix(String),
Copy link
Collaborator

@danielhenrymantilla danielhenrymantilla May 17, 2022

Choose a reason for hiding this comment

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

🤔 what do you think of:

Suggested change
Default,
Suffix(String),
Prefix(String),
Default,
Custom(fn(&str) -> String),

it would be more general, and would still allow suffix and prefix with things like: Custom(|s| format!("{s}_t")).


Otherwise we could handle them all 🤷

Suggested change
Default,
Suffix(String),
Prefix(String),
Default,
Suffix(String),
Prefix(String),
Custom(fn(&str) -> String),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handling them all is nice because we could handle something like :

#[ffi_export(prefix="PFX")]
struct Foo {...}

@ronan-ditto ronan-ditto merged commit 561d470 into cleanup-replace-macro-rules-with-proc-macros May 18, 2022
@ronan-ditto ronan-ditto deleted the rd/customizable-naming-templates-eg-namespace-prefixing branch May 18, 2022 06:31
@ronan-ditto ronan-ditto restored the rd/customizable-naming-templates-eg-namespace-prefixing branch May 18, 2022 07:24
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.

Customizable naming templates (e.g., namespace prefixing)
2 participants