The other day I decided to try some Rust again, now that they've reached 1.0. After reading most of Rust By Example, I decided it was time to check if I'd learnt anything.

As a first exercise, I implemented a slugify function, that takes a string like Testing! 123, ÆØÅ, and returns a URL-friendly version like testing-123-aeoeaa.

If you came here from the Gist on Github: There is a better version of Slugify available, that you should probably use instead. It handles more special character using the unidecode library (which I didn't know existed when I wrote mine). It's also in cargo. You can find it here:

I haven't done any direct comparisons of my function vs slug-rs, so I don't know which performs better. Feel free to use my version if you feel like it (do whatever you want with it -- it's in the Public Domain).

Thanks to the helpful people in #rust @ for feedback!