Hi, thank for the nice crate, it save me time and boilerplate today!
Motivaiton
This modifiers like $var:snake:upper are very helpful and prevents from some repetition.
However, sometimes there are not sufficient, there some cases when a thing needs to be converted to it's plural (or maybe singular form).
For example: it would be cool to be able to derive from User model a table where it's stored (users).
Examples
when $var = user
$var:plural => users
$var:singular => user
when $var = users
$var:plural => users
$var:singular => user
Challenges
Due to the English grammar, just adding s is not always sufficient.
For example:
Hi, thank for the nice crate, it save me time and boilerplate today!
Motivaiton
This modifiers like
$var:snake:upper
are very helpful and prevents from some repetition. However, sometimes there are not sufficient, there some cases when a thing needs to be converted to it's plural (or maybe singular form).For example: it would be cool to be able to derive from
User
model a table where it's stored (users
).Examples
$var = user
$var:plural
=>users
$var:singular
=>user
$var = users
$var:plural
=>users
$var:singular
=>user
Challenges
Due to the English grammar, just adding
s
is not always sufficient. For example:So the problem is not very trivial. A good news, that Rails has it for almost 2 decades, and we can peek some ideas there. In Rails, the module responsible for this is called Inflector: https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html
It seems to be that this problem also already solved in Rust. There are plenty of crates doing this: https://crates.io/search?q=singular%20plural inflection-rs seems to be the most decent among them.
I'd like to hear from you:
paste
crate?Thank you in advance!