Function slug::slugify
[−]
[src]
pub fn slugify<S: AsRef<str>>(s: S) -> String
Convert any unicode string to an ascii "slug" (useful for file names/url components)
The returned "slug" will consist of a-z, 0-9, and '-'. Furthermore, a slug will never contain more than one '-' in a row and will never start or end with '-'.
use self::slug::slugify; assert_eq!(slugify("My Test String!!!1!1"), "my-test-string-1-1"); assert_eq!(slugify("test\nit now!"), "test-it-now"); assert_eq!(slugify(" --test_-_cool"), "test-cool"); assert_eq!(slugify("Æúű--cool?"), "aeuu-cool"); assert_eq!(slugify("You & Me"), "you-me"); assert_eq!(slugify("user@example.com"), "user-example-com");