pub enum CaseStyle {
LowerHyphen,
LowerUnderscore,
LowerCamel,
UpperCamel,
UpperUnderscore,
}Expand description
Naming styles supported by this crate.
The conversion rules are intended for ASCII identifiers. Non-ASCII input is accepted on a best-effort basis, but its exact conversion behavior is not a stable contract.
Variants§
LowerHyphen
Hyphen separated lowercase words, such as lower-hyphen.
LowerUnderscore
Underscore separated lowercase words, such as lower_underscore.
LowerCamel
Lower camel case words, such as lowerCamel.
UpperCamel
Upper camel case words, such as UpperCamel.
UpperUnderscore
Underscore separated uppercase words, such as UPPER_UNDERSCORE.
Implementations§
Source§impl CaseStyle
impl CaseStyle
Sourcepub const LOWER_HYPHEN: Self = Self::LowerHyphen
pub const LOWER_HYPHEN: Self = Self::LowerHyphen
XML hyphenated variable naming style, such as lower-hyphen.
Sourcepub const LOWER_UNDERSCORE: Self = Self::LowerUnderscore
pub const LOWER_UNDERSCORE: Self = Self::LowerUnderscore
C++/Python variable naming style, such as lower_underscore.
Sourcepub const LOWER_CAMEL: Self = Self::LowerCamel
pub const LOWER_CAMEL: Self = Self::LowerCamel
Java variable naming style, such as lowerCamel.
Sourcepub const UPPER_CAMEL: Self = Self::UpperCamel
pub const UPPER_CAMEL: Self = Self::UpperCamel
Java and C++ class naming style, such as UpperCamel.
Sourcepub const UPPER_UNDERSCORE: Self = Self::UpperUnderscore
pub const UPPER_UNDERSCORE: Self = Self::UpperUnderscore
Java and C++ constant naming style, such as UPPER_UNDERSCORE.
Sourcepub const fn values() -> &'static [Self; 5]
pub const fn values() -> &'static [Self; 5]
Returns all supported naming styles in the reference implementation order.
§Returns
Returns a static slice containing all naming styles.
Sourcepub fn of(name: &str) -> Result<Self, CaseStyleError>
pub fn of(name: &str) -> Result<Self, CaseStyleError>
Parses a naming style from its canonical name.
The comparison is case-insensitive, and hyphen and underscore are treated as equivalent separators.
§Parameters
name- Naming style name to parse.
§Returns
Returns the parsed naming style, or CaseStyleError carrying the
original name when no style matches.
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
Returns the canonical name of this naming style.
§Returns
Returns the lower-hyphen style name used by the JavaScript reference implementation.
Sourcepub const fn word_separator(self) -> &'static str
pub const fn word_separator(self) -> &'static str
Returns the word separator inserted by this naming style.
§Returns
Returns "-" for lower hyphen, "_" for underscore styles, and ""
for camel case styles.