pub fn apply_to_field(&self, field: &str) -> String {
        match *self {
            Self::LowerCase | Self::SnakeCase => field.to_owned(),
            Self::UpperCase => field.to_ascii_uppercase(),
            Self::PascalCase => {
                let mut pascal = String::new();
                let mut capitalize = true;
                for ch in field.chars() {
                    if ch == '_' {
                        capitalize = true;
                    } else if capitalize {
                        pascal.push(ch.to_ascii_uppercase());
                        capitalize = false;
                    } else {
                        pascal.push(ch);
                    }
                }
                pascal
            }
            Self::CamelCase => {
                let pascal = Self::PascalCase.apply_to_field(field);
                pascal[..1].to_ascii_lowercase() + &pascal[1..]
            }
            Self::ScreamingSnakeCase => field.to_ascii_uppercase(),
            Self::KebabCase => field.replace('_', "-"),
            Self::ScreamingKebabCase => Self::ScreamingSnakeCase
                .apply_to_field(field)
                .replace('_', "-"),
        }
    }
/// Apply a renaming rule to a struct field, returning the version expected in the source.
Apply a renaming rule to a struct field, returning the version expected in the source.
Apply a renaming rule to a struct field returning the version expected in the source .
pub fn apply_to_field(&self, field: &str) -> String {
        match *self {
            Self::LowerCase | Self::SnakeCase => field.to_owned(),
            Self::UpperCase => field.to_ascii_uppercase(),
            Self::PascalCase => {
                let mut pascal = String::new();
                let mut capitalize = true;
                for ch in field.chars() {
                    if ch == '_' {
                        capitalize = true;
                    } else if capitalize {
                        pascal.push(ch.to_ascii_uppercase());
                        capitalize = false;
                    } else {
                        pascal.push(ch);
                    }
                }
                pascal
            }
            Self::CamelCase => {
                let pascal = Self::PascalCase.apply_to_field(field);
                pascal[..1].to_ascii_lowercase() + &pascal[1..]
            }
            Self::ScreamingSnakeCase => field.to_ascii_uppercase(),
            Self::KebabCase => field.replace('_', "-"),
            Self::ScreamingKebabCase => Self::ScreamingSnakeCase
                .apply_to_field(field)
                .replace('_', "-"),
        }
    }
pub fn apply_to_field ( & self , field : & str ) -> String { match * self { Self :: LowerCase | Self :: SnakeCase => field . to_owned ( ) , Self :: UpperCase => field . to_ascii_uppercase ( ) , Self :: PascalCase => { let mut pascal = String :: new ( ) ; let mut capitalize = true ; for ch in field . chars ( ) { if ch == '_' { capitalize = true ; } else if capitalize { pascal . push ( ch . to_ascii_uppercase ( ) ) ; capitalize = false ; } else { pascal . push ( ch ) ; } } pascal } Self :: CamelCase => { let pascal = Self :: PascalCase . apply_to_field ( field ) ; pascal [ .. 1 ] . to_ascii_lowercase ( ) + & pascal [ 1 .. ] } Self :: ScreamingSnakeCase => field . to_ascii_uppercase ( ) , Self :: KebabCase => field . replace ( '_' , " " ) , Self :: ScreamingKebabCase => Self :: ScreamingSnakeCase . apply_to_field ( field ) . replace ( '_' , " " ) , } }
Apply a renaming rule to a struct field, returning the version expected in the source.
Apply a renaming rule to a struct field returning the version expected in the source .
&self
field
&str
&self
field
&str