|0.3.1||Mar 13, 2021|
|0.3.0||Mar 13, 2021|
|0.2.1||Mar 13, 2021|
|0.2.0||Sep 25, 2019|
|0.1.0||Sep 24, 2019|
#287 in Data structures
4,059 downloads per month
Used in diffus
The purpose of this crate is to expose the type
SnakeCase, a wrapper around a
String that can only contain valid, non-empty snake_case without leading digits. In other words, it always matches
- Starts with a lower case ASCII letter or underscore
- Contains only lower case ASCII letters, underscores and digits
___foo__bar_ is considered valid snake case by this crate.
SnakeCase can hold any string that is also a valid lower case identifier in Rust.
The common case for this is unique identifiers, for which snake case is perfectly suited.
SnakeCase will always be valid, meaning you will never have the problem of trailing spaces or empty strings.
let id = SnakeCase::try_from_str("hello_world").unwrap(); assert_eq!(id, "hello_world");
There is also
SnakeCaseRef which is a non-owning reference to a snake_case string.
If you enable the
"serde" feature then
SnakeCase will implement
Deserialize will fail if a string is not valid snake case.