[][src]Struct str_slug::StrSlug

pub struct StrSlug {
    pub use_hash: bool,
    pub append_hash: bool,
    pub hash_len: usize,
    pub hash_separator: char,
    pub separator: char,
    pub remove_duplicate_separators: bool,
    pub trim_separator: bool,
    pub trim_separator_start: bool,
    pub trim_separator_end: bool,
}

Fields

use_hash: boolappend_hash: bool

if its set to false the hash will be prepended

hash_len: usize

use full hash if hash_len = 0

hash_separator: char

separator to use to separate slug and hash

separator: charremove_duplicate_separators: booltrim_separator: bool

Trim leading and trailing separators after slugifying the given string.

trim_separator_start: booltrim_separator_end: bool

Methods

impl StrSlug[src]

pub fn new() -> Self[src]

pub fn slug<T: AsRef<str>>(&self, value: T) -> String[src]

Generate a slug for the given value by applying user options.

Examples

Normal usage

use str_slug::StrSlug;

let str_slug = StrSlug::new();
let slug = str_slug::slug("Hello, World!");
assert_eq!(slug, "hello-world");

Hashed slug

use str_slug::StrSlug;

let mut str_slug = StrSlug::new();
str_slug.use_hash = true;

let slug = str_slug.slug("Hello, World!");
assert_eq!(slug, "hello-world_288a86");

Auto Trait Implementations

impl RefUnwindSafe for StrSlug

impl Send for StrSlug

impl Sync for StrSlug

impl Unpin for StrSlug

impl UnwindSafe for StrSlug

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.