-
Notifications
You must be signed in to change notification settings - Fork 4
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: Client improvements #6
Conversation
|
||
let mut output = String::with_capacity(ident.len()); | ||
for (i, ch) in ident.char_indices() { | ||
if i > 0 && ch.is_ascii_uppercase() { |
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.
Do I get it right that this assumes that the ident is always in UpperCamelCase?
If so, is it also expected that acronyms are always treated like words?
E.g. looked like this would transform HTTPStatus
to h_t_t_p_status
via SnakeCase
.
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.
Also, do we want to break on digits? E.g. Status500
-> status_500
?
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.
I've consulted the serde
impl 🙃 It does have the peculiarities you've described:
- It assumes that the input is PascalCase. IMO, it's a reasonable assumption to make; I guess we can document it.
- Acronyms are tricky. IIRC, Rust best practices recommend to capitalize only the first letter of acronyms (i.e.,
HttpStatus
rather thanHTTPStatus
). In any case, in these situations one can specify the name override explicitly. - Breaking on digits is tricky as well; I feel there's no obvious way to insert or not insert a
_
before them. Again, it's possible to specify the name override to make it explicit.
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.
Yeah, I don't suggest changing anything, just wanted to check whether this was considered.
Probably it indeed makes sense to document this behavior.
IIRC, Rust best practices recommend to capitalize only the first letter of acronyms
Well, yeah, there is a clippy lint for that, but it's ranked 4th in the list of most commonly ignored lints. Looks like the community doesn't agree with this best practice :)
What ❔
Improves the client crate in various ways:
Gauge
s for more types, e.g.usize
/isize
.r#type
) as label names.serde
.Why ❔
Makes the crate easier to use (with the guiding example being the main Era repo).
Checklist
cargo fmt
andcargo clippy
.