Conversation
Casing belongs to the renderers, not the node model, so this is a plain function next to the other syn helpers rather than a newtype in codama-nodes. It exists so a Rust code generator can turn an identifier of any casing into a snake_case one without pulling in heck. Word boundaries: an uppercase run splits before its last letter when a lowercase letter follows, so HTTPServer gives http_server and tokenAMint gives token_a_mint. A digit ends a word only when an uppercase letter follows a lowercase run, so seed2Bump gives seed2_bump while mint_2 and this123 are left alone. That matches heck::ToSnakeCase, checked by differential fuzzing over 1.2 million ASCII inputs with zero mismatches. The only divergence found on non-ASCII input is a word-final Greek capital sigma, which heck lowercases to the final form and this lowercases per character. The function drops non-alphanumeric characters, so the result can be empty or start with a digit. Turning one into a valid Ident is the caller's job and is documented as such.
Member
|
Is this something v1 requires right now or could this wait post-v2? |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.