ncase 0.3.2

Enforce a case style
Documentation
//! `ncase` [ɪn'keɪs] is a library to enforce case styles.
//!
//! ## Usage
//!
//! Use the [free functions](#functions) for one-off case conversions.
//! They automatically split the input string into words just as
//! [`Words::from`]
//!
//! ```
//! assert_eq!(ncase::camel("camel case"), "camelCase");
//! assert_eq!(ncase::snake("snake case"), "snake_case");
//! ```
//!
//! Use [`Words`] if you need to convert one string into many case styles
//!
//! ```
//! use ncase::Words;
//!
//! let s = "Lorem ipsum dolor sit amet";
//! let w = Words::from(s);
//!
//! assert_eq!(w.kebab(), "lorem-ipsum-dolor-sit-amet");
//! assert_eq!(w.title(), "Lorem Ipsum Dolor Sit Amet");
//! ```
//!
//! Or if you want to use a separator regex (the `regex` feature)
//!
//! ```
//! use ncase::Words;
//! use regex::Regex;
//!
//! let s = "Lorem, ipsum (dolor _sit)_ amet";
//! let sep = Regex::new(r"[\pP\s]+").unwrap();
//! let w = Words::with_separator(s, &sep);
//!
//! assert_eq!(w.lower(), "lorem ipsum dolor sit amet");
//! assert_eq!(w.upper(), "LOREM IPSUM DOLOR SIT AMET");
//! ```
//!
//! ## Features
//!
//! `regex`
//! : Enables [`Words::with_separator`] in the library and `-F <separator>`
//!   in the binary. Adds the `regex` dependency.
//!
//! `rand`
//! : Enables `rANdOm cASe` support. Adds the `rand` dependency.

mod case;
mod words;

pub use words::Words;

macro_rules! free_fn {
    ($name:ident) => {
        #[doc = concat!("Free form of [`Words::", stringify!($name), "`].")]
        pub fn $name(s: &str) -> String {
            Words::from(s).$name()
        }
    };
}

free_fn!(camel);
free_fn!(pascal);
free_fn!(kebab);
free_fn!(screaming_kebab);
free_fn!(lower);
free_fn!(upper);
free_fn!(snake);
free_fn!(screaming_snake);
free_fn!(title);
free_fn!(toggle);
#[cfg(feature = "rand")]
free_fn!(random);