pub trait ToSanitizedCase {
    // Required methods
    fn to_sanitized_pascal_case(&self) -> Cow<'_, str>;
    fn to_sanitized_constant_case(&self) -> Cow<'_, str>;
    fn to_sanitized_not_keyword_snake_case(&self) -> Cow<'_, str>;

    // Provided methods
    fn to_pascal_case_ident(&self, span: Span) -> Ident { ... }
    fn to_constant_case_ident(&self, span: Span) -> Ident { ... }
    fn to_sanitized_snake_case(&self) -> Cow<'_, str> { ... }
    fn to_snake_case_ident(&self, span: Span) -> Ident { ... }
}
Expand description

Convert self string into specific case without overlapping to svd2rust internal names

Required Methods§

source

fn to_sanitized_pascal_case(&self) -> Cow<'_, str>

Convert self into PascalCase.

Use on name of enumeration values.

source

fn to_sanitized_constant_case(&self) -> Cow<'_, str>

Convert self into CONSTANT_CASE.

Use on name of reader structs, writer structs and enumerations.

source

fn to_sanitized_not_keyword_snake_case(&self) -> Cow<'_, str>

Convert self into snake_case, must use only if the target is used with extra prefix or suffix.

Provided Methods§

source

fn to_pascal_case_ident(&self, span: Span) -> Ident

source

fn to_constant_case_ident(&self, span: Span) -> Ident

source

fn to_sanitized_snake_case(&self) -> Cow<'_, str>

Convert self into snake_case target and ensure target is not a Rust keyword.

If the sanitized target is a Rust keyword, this function adds an underline _ to it.

Use on name of peripheral modules, register modules and field modules.

source

fn to_snake_case_ident(&self, span: Span) -> Ident

Implementations on Foreign Types§

source§

impl ToSanitizedCase for str

Implementors§