(&self)
| 391 | |
| 392 | impl ToMoonBitIdent for str { |
| 393 | fn to_moonbit_ident(&self) -> String { |
| 394 | // Escape MoonBit keywords and reserved keywords |
| 395 | match self { |
| 396 | // Keywords |
| 397 | "as" | "else" | "extern" | "fn" | "fnalias" | "if" | "let" | "const" | "match" | "using" |
| 398 | | "mut" | "type" | "typealias" | "struct" | "enum" | "trait" | "traitalias" | "derive" |
| 399 | | "while" | "break" | "continue" | "import" | "return" | "throw" | "raise" | "try" | "catch" |
| 400 | | "pub" | "priv" | "readonly" | "true" | "false" | "_" | "test" | "loop" | "for" | "in" | "impl" |
| 401 | | "with" | "guard" | "async" | "is" | "suberror" | "and" | "letrec" | "enumview" | "noraise" |
| 402 | | "defer" | "init" | "main" |
| 403 | // Reserved keywords |
| 404 | | "module" | "move" | "ref" | "static" | "super" | "unsafe" | "use" | "where" | "await" |
| 405 | | "dyn" | "abstract" | "do" | "final" | "macro" | "override" | "typeof" | "virtual" | "yield" |
| 406 | | "local" | "method" | "alias" | "assert" | "package" | "recur" | "isnot" | "define" | "downcast" |
| 407 | | "inherit" | "member" | "namespace" | "upcast" | "void" | "lazy" | "include" | "mixin" |
| 408 | | "protected" | "sealed" | "constructor" | "atomic" | "volatile" | "anyframe" | "anytype" |
| 409 | | "asm" | "comptime" | "errdefer" | "export" | "opaque" | "orelse" | "resume" | "threadlocal" |
| 410 | | "unreachable" | "dynclass" | "dynobj" | "dynrec" | "var" | "finally" | "noasync" => { |
| 411 | format!("{self}_") |
| 412 | } |
| 413 | _ => self.strip_prefix("[async]").unwrap_or(self).to_snake_case(), |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | pub(crate) trait ToMoonBitTypeIdent: ToOwned { |
no outgoing calls
no test coverage detected