Today marks the official release of the v0.0.3 version of typed-ident!
This update is mainly for cleanup, and to correct some API inconsistencies and lingering design problems. After this release there will be a lapse in updates while I work on some other projects to gain some experience using this new crate.
You can add the dependency by editing your Cargo.toml:
[dependencies]
typed-ident = "0.0.3"
Or by using cargo add:
cargo add typed-ident
Or update by using cargo update:
cargo update -p typed-ident
Both the fmt and convert modules have had substantial clean-up.
The biggest change has been the traits now return a generic type. This was originally avoided because generic return parameters can sometimes be annoying. However, it makes sense here because the result can be applied to many different types (originally it just returned a String).
let ident = LowerCamelIdent::new("lowerCamelIdent")?;
let converted: String = ident.to_upper_snake()?;
let converted: Box<UpperSnakeIdent> = ident.to_upper_snake()?;
let converted: Box<CasedSnakeIdent> = ident.to_upper_snake()?;
let converted: Box<SnakeIdent> = ident.to_upper_snake()?;
let converted: Box<str> = ident.to_upper_snake()?;
Which types can be produced depends on whats known as the “intermediate value”.
For ToUpperSnake, the intermediate value is UpperSnakeIdent, and so you can assign that value to either any owned string type (String or Box<str>), or you can assign it to any boxed typed-ident that you would have been able to trivially cast the result to.
“Words” are subslices of chunks of an identifier which contain no boundaries.
It originally was the case that only a Chunk could iterate over words. It was originally done this way because Words is defined in relation to Chunk, and it might seem strange to automatically drop Delimiters (which aren’t, and never can be, a word).
However, there were many cases where iteration over words, intentionally dropping delimiters popped up. So, it was decided that this functionality would receive proper support on a Fragment (and thus Ident, which can Deref<Target = Fragment>).
let ident = LowerCamelIdent::new("lowerCamel_ident")?;
let words: Vec<_> = ident.words().type_erased().collect();
assert_eq!(words, vec!["lower", "Camel", "ident"]);
The documentation continues to be iterated upon as development progresses.
Some stand-out improvements in the documentation are:
- functionality is now tagged with feature badges
- the main crate documentation had major changes
- clear demonstrations of conversion functions
There were numerous other fixes to the documentation as well. However, it’s a bit large of an API, so it’s difficult to find issues myself. If you notice anything, don’t hesitate to open an issue.
There were many other changes that aren’t worth highlighting. Many of them improve the usability of the crate, or fix inconsistencies with the design or naming. Most of them are breaking changes, so you may need to make code changes after updating.
The goal is to get all the breaking changes out of the way early. As a quick reminder, until the project claims beta (v0.1.0), you should assume most alpha updates to include breaking changes.
You can view the complete list of important changes in the changelog.
Thanks for reading, and I hope these improvements are useful for you!