Crate rslug

Crate rslug 

Source
Expand description

§rslug

A simple, fast, and configurable Rust library to create URL-friendly slugs from strings, with great support for Unicode.

This library is inspired by popular slugify libraries in other languages and aims to be a robust solution for Rust applications.

§Quick Start

The easiest way to use the library is with the slugify! macro.

use rslug::slugify;

let text = "Hello World! This is a test... 123?";
let slug = slugify!(text);
assert_eq!(slug, "hello-world-this-is-a-test-123");

let unicode_text = "你好世界 & Rust";
let unicode_slug = slugify!(unicode_text);
assert_eq!(unicode_slug, "nihaoshijie-rust");

§Advanced Configuration

For more control over the slug generation, you can use the Slugifier builder. This allows you to set a custom separator, control case, and more.

use rslug::Slugifier;

// Create a custom slugifier with an underscore separator
let slugifier = Slugifier::new()
    .separator("_");

let text = "Custom Separator Example!";
let slug = slugifier.slugify(text);

assert_eq!(slug, "custom_separator_example");

Macros§

slugify
A convenient macro to slugify a string with default settings.
slugify_ascii

Structs§

Slugifier
A configurable slug generator.