slugrs 0.2.3

A fast, locale-aware slugify library for Rust
Documentation
use regex::Regex;

/// Configurable options for slugification.
#[derive(Debug, Clone)]
pub struct Options {
    /// Word separator to use in the final slug.
    pub separator: String,
    /// Optional locale mapping for language-specific transliteration rules.
    pub locale: Option<crate::Locale>,
    /// Optional regex to remove characters before processing.
    pub remove: Option<Regex>,
    /// Convert the result to lowercase (default: true)
    pub lowercase: bool,
    /// Trim leading/trailing separators (default: true)
    pub trim: bool,
    /// Maximum length of the slug in characters (None = unlimited)
    pub max_length: Option<usize>,
}

impl Default for Options {
    fn default() -> Self {
        Self {
            separator: "-".into(),
            locale: None,
            remove: None,
            lowercase: true,
            trim: true,
            max_length: None,
        }
    }
}

impl Options {
    pub fn separator(mut self, separator: impl Into<String>) -> Self {
        self.separator = separator.into();
        self
    }

    pub fn locale(mut self, locale: Option<crate::Locale>) -> Self {
        self.locale = locale;
        self
    }

    pub fn remove(mut self, remove: Option<Regex>) -> Self {
        self.remove = remove;
        self
    }

    pub fn lowercase(mut self, lowercase: bool) -> Self {
        self.lowercase = lowercase;
        self
    }

    pub fn trim(mut self, trim: bool) -> Self {
        self.trim = trim;
        self
    }

    pub fn max_length(mut self, max_length: Option<usize>) -> Self {
        self.max_length = max_length;
        self
    }
}