Convert a names of sql schemes from camelcase to snake case.
Taking data as str.
This crate #[names_changer]
provides trait method .camel_to_snake()
that convert a names from camel case to snake case.
The trait searches for words matching the pattern and converts them to snake case.
First of all you have to add this dependency to your Cargo.toml
:
toml
[dev-dependencies]
names-changer = "0.2.0"
Additionally, you have to import the procedural macro with use
statement:
rust
use names_changer::NamesChanger;
```rust #[cfg(test)] mod tests { use names_changer::NamesChanger;
// Not needed for this example, but useful in general
use super::*;
#[test]
fn test_name_change() {
let content = "TABLE ClientTokensRef IS 'text';";
let change_content = content.camel_to_snake();
assert_eq!("TABLE client_tokens_ref IS 'text';", change_content)
}
} ```
0.2.0
- fixed bug with method name
- added recursive processing of segments without spaces:
from "(ClientRefA (ClientRefB (ClientRefC ((ClientRefE (id)))))"
we get "(clientrefa (clientrefb (clientrefc ((clientrefe (id)))))"
- added tests
- case
crate (the have problems with abbreviations) replaced with heck
Cons: requires a lot of resources, not optimized.
This project is licensed under either of