Skip to main content

is_case

Function is_case 

Source
pub fn is_case<T: AsRef<str>>(s: T, case: Case<'_>) -> bool
Expand description

Checks if a string matches the specified case.

A string matches a case if converting it to that case produces the same string (i.e., s.to_case(case) == s).

ยงExample

use convert_case::Case;
use convert_case_extras::is_case;

assert!(is_case("hello_world", Case::Snake));
assert!(!is_case("hello_world", Case::Kebab));
assert!(is_case("HelloWorld", Case::Pascal));