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: bool
§append_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: char
§remove_duplicate_separators: bool
§trim_separator: bool
Trim leading and trailing separators after slugifying the given string.
trim_separator_start: bool
§trim_separator_end: bool
Implementations§
Source§impl StrSlug
impl StrSlug
pub fn new() -> Self
Sourcepub fn slug<T: AsRef<str>>(&self, value: T) -> String
pub fn slug<T: AsRef<str>>(&self, value: T) -> String
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 Freeze for StrSlug
impl RefUnwindSafe for StrSlug
impl Send for StrSlug
impl Sync for StrSlug
impl Unpin for StrSlug
impl UnwindSafe for StrSlug
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more