-
Notifications
You must be signed in to change notification settings - Fork 43
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
[WIP]Custom names for structs, enums & functions #108
Conversation
* Builder::generate_with_definer has been splitted in subfunction for better readability * added type alias GenerationFunction * added NameConvention option on builder
d1a1ee7
to
8c0a706
Compare
There was a problem hiding this 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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.guard.unwrap_or( | |
self.guard.map_or_else(|| |
env::var("CARGO_PKG_NAME") | ||
.unwrap() | ||
.to_ascii_uppercase() | ||
)).to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)).to_string() | |
), str::to_string) |
|
||
fn guard(&self) -> String { | ||
self.guard.unwrap_or( | ||
&format!("__RUST_{}__", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&format!("__RUST_{}__", | |
format!("__RUST_{}__", |
Default, | ||
Suffix(String), | ||
Prefix(String), |
There was a problem hiding this comment.
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:
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 🤷
Default, | |
Suffix(String), | |
Prefix(String), | |
Default, | |
Suffix(String), | |
Prefix(String), | |
Custom(fn(&str) -> String), |
There was a problem hiding this comment.
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 {...}
better readability