pub fn apply_to_variant(&self, variant: &str) -> String {
        match *self {
            Self::PascalCase => variant.to_owned(),
            Self::LowerCase => variant.to_ascii_lowercase(),
            Self::UpperCase => variant.to_ascii_uppercase(),
            Self::CamelCase => variant[..1].to_ascii_lowercase() + &variant[1..],
            Self::SnakeCase => {
                let mut snake = String::new();
                for (i, ch) in variant.char_indices() {
                    if i > 0 && ch.is_uppercase() {
                        snake.push('_');
                    }
                    snake.push(ch.to_ascii_lowercase());
                }
                snake
            }
            Self::ScreamingSnakeCase => Self::SnakeCase
                .apply_to_variant(variant)
                .to_ascii_uppercase(),
            Self::KebabCase => Self::SnakeCase.apply_to_variant(variant).replace('_', "-"),
            Self::ScreamingKebabCase => Self::ScreamingSnakeCase
                .apply_to_variant(variant)
                .replace('_', "-"),
        }
    }
/// Apply a renaming rule to an enum variant, returning the version expected in the source.
Apply a renaming rule to an enum variant, returning the version expected in the source.
Apply a renaming rule to an enum variant returning the version expected in the source .
pub fn apply_to_variant(&self, variant: &str) -> String {
        match *self {
            Self::PascalCase => variant.to_owned(),
            Self::LowerCase => variant.to_ascii_lowercase(),
            Self::UpperCase => variant.to_ascii_uppercase(),
            Self::CamelCase => variant[..1].to_ascii_lowercase() + &variant[1..],
            Self::SnakeCase => {
                let mut snake = String::new();
                for (i, ch) in variant.char_indices() {
                    if i > 0 && ch.is_uppercase() {
                        snake.push('_');
                    }
                    snake.push(ch.to_ascii_lowercase());
                }
                snake
            }
            Self::ScreamingSnakeCase => Self::SnakeCase
                .apply_to_variant(variant)
                .to_ascii_uppercase(),
            Self::KebabCase => Self::SnakeCase.apply_to_variant(variant).replace('_', "-"),
            Self::ScreamingKebabCase => Self::ScreamingSnakeCase
                .apply_to_variant(variant)
                .replace('_', "-"),
        }
    }
pub fn apply_to_variant ( & self , variant : & str ) -> String { match * self { Self :: PascalCase => variant . to_owned ( ) , Self :: LowerCase => variant . to_ascii_lowercase ( ) , Self :: UpperCase => variant . to_ascii_uppercase ( ) , Self :: CamelCase => variant [ .. 1 ] . to_ascii_lowercase ( ) + & variant [ 1 .. ] , Self :: SnakeCase => { let mut snake = String :: new ( ) ; for ( i , ch ) in variant . char_indices ( ) { if i > 0 && ch . is_uppercase ( ) { snake . push ( '_' ) ; } snake . push ( ch . to_ascii_lowercase ( ) ) ; } snake } Self :: ScreamingSnakeCase => Self :: SnakeCase . apply_to_variant ( variant ) . to_ascii_uppercase ( ) , Self :: KebabCase => Self :: SnakeCase . apply_to_variant ( variant ) . replace ( '_' , " " ) , Self :: ScreamingKebabCase => Self :: ScreamingSnakeCase . apply_to_variant ( variant ) . replace ( '_' , " " ) , } }
Apply a renaming rule to an enum variant, returning the version expected in the source.
Apply a renaming rule to an enum variant returning the version expected in the source .
&self
variant
&str
&self
variant
&str