Skip to content

feat:snake case syn helper - #139

Closed
senzenn wants to merge 2 commits into
codama-idl:mainfrom
senzenn:feat/snake-case-syn-helper
Closed

senzenn wants to merge 2 commits into
codama-idl:mainfrom
senzenn:feat/snake-case-syn-helper

Conversation

@senzenn

@senzenn senzenn commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

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.
@senzenn senzenn changed the title Feat/snake case syn helper feat:snake case syn helper Sep 2, 2026
@lorisleiva

Copy link
Copy Markdown
Member

Is this something v1 requires right now or could this wait post-v2?

@senzenn

senzenn commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

It can wait. Nothing in v1 needs it. No call sites on this branch, and nothing on main uses it. #86 was the only consumer and it already carries the same ident.rs on its own branch, so splitting it out here doesn't unblock anything. With #86 waiting for v2 this should wait with Closing .

@senzenn senzenn closed this Sep 3, 2026
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.

2 participants