{ "name": "Rust", "scopeName": "source.rust", "patterns": [ { "begin": "\\b(impl)\\b", "end": "\\{", "patterns": [ { "include": "#block_comment" }, { "include": "#line_comment" }, { "include": "#sigils" }, { "include": "#mut" }, { "include": "#ref_lifetime" }, { "include": "#core_types" }, { "include": "#core_marker" }, { "include": "#core_traits" }, { "include": "#std_types" }, { "include": "#std_traits" }, { "include": "#type_params" }, { "include": "#where" }, { "name": "storage.type.rust", "match": "\\bfor\\b" }, { "include": "#type" } ], "beginCaptures": { "1": { "name": "storage.type.rust" } } }, { "include": "#block_doc_comment" }, { "include": "#block_comment" }, { "include": "#line_doc_comment" }, { "include": "#line_comment" }, { "name": "meta.attribute.rust", "begin": "#\\!?\\[", "end": "\\]", "patterns": [ { "include": "#string_literal" }, { "include": "#block_doc_comment" }, { "include": "#block_comment" }, { "include": "#line_doc_comment" }, { "include": "#line_comment" } ] }, { "name": "string.quoted.single.rust", "match": "b?'([^'\\\\]|\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.))'" }, { "include": "#string_literal" }, { "include": "#raw_string_literal" }, { "name": "constant.numeric.float.rust", "match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9_]+)?(f32|f64)?\\b" }, { "name": "constant.numeric.float.rust", "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9_]+(f32|f64)?\\b" }, { "name": "constant.numeric.float.rust", "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9_]+)?(f32|f64)\\b" }, { "name": "constant.numeric.integer.decimal.rust", "match": "\\b[0-9][0-9_]*([ui](8|16|32|64|128|s|size))?\\b" }, { "name": "constant.numeric.integer.hexadecimal.rust", "match": "\\b0x[a-fA-F0-9_]+([ui](8|16|32|64|128|s|size))?\\b" }, { "name": "constant.numeric.integer.octal.rust", "match": "\\b0o[0-7_]+([ui](8|16|32|64|128|s|size))?\\b" }, { "name": "constant.numeric.integer.binary.rust", "match": "\\b0b[01_]+([ui](8|16|32|64|128|s|size))?\\b" }, { "name": "storage.modifier.static.rust", "match": "\\bstatic\\b" }, { "name": "constant.language.boolean.rust", "match": "\\b(true|false)\\b" }, { "name": "keyword.control.rust", "match": "\\b(break|continue|else|if|in|for|loop|match|return|while)\\b" }, { "name": "keyword.other.rust", "match": "\\b(crate|extern|mod|let|ref|use|super|move)\\b" }, { "name": "invalid.deprecated.rust", "match": "\\b(abstract|alignof|become|do|final|macro|offsetof|override|priv|proc|pure|sizeof|typeof|virtual|yield)\\b" }, { "include": "#unsafe" }, { "include": "#sigils" }, { "include": "#self" }, { "include": "#mut" }, { "include": "#box" }, { "include": "#lifetime" }, { "include": "#ref_lifetime" }, { "include": "#const" }, { "include": "#pub" }, { "name": "keyword.operator.misc.rust", "match": "(=\u003e|::|\\bas\\b)" }, { "name": "keyword.operator.comparison.rust", "match": "(\u0026\u0026|\\|\\||==|!=)" }, { "name": "keyword.operator.assignment.rust", "match": "(\\+=|-=|/=|\\*=|%=|\\^=|\u0026=|\\|=|\u003c\u003c=|\u003e\u003e=|=)" }, { "name": "keyword.operator.arithmetic.rust", "match": "(!|\\+|-|/|\\*|%|\\^|\u0026|\\||\u003c\u003c|\u003e\u003e)" }, { "name": "keyword.operator.comparison.rust", "match": "(\u003c=|\u003e=|\u003c|\u003e)" }, { "include": "#core_types" }, { "include": "#core_vars" }, { "include": "#core_marker" }, { "include": "#core_traits" }, { "include": "#std_types" }, { "include": "#std_traits" }, { "name": "support.function.builtin.rust", "match": "\\b(macro_rules|compile_error|format_args|env|option_env|concat_idents|concat|line|column|file|stringify|include|include_str|include_bytes|module_path|cfg)!" }, { "name": "support.function.core.rust", "match": "\\b(panic|assert|assert_eq|assert_ne|debug_assert|debug_assert_eq|debug_assert_ne|try|write|writeln|unreachable|unimplemented)!" }, { "name": "support.function.std.rust", "match": "\\b(format|print|println|eprint|eprintln|select|vec)!" }, { "name": "support.function.log.rust", "match": "\\b(log|error|warn|info|debug|trace|log_enabled)!" }, { "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*\\!)\\s*[({\\[]", "captures": { "1": { "name": "entity.name.function.macro.rust" } } }, { "match": "\\b([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)\\s*\\(", "captures": { "1": { "name": "entity.name.function.rust" } } }, { "begin": "\\b([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)\\s*(::)(?=\\s*\u003c.*\u003e\\s*\\()", "end": "\\(", "patterns": [ { "include": "#type_params" } ], "captures": { "1": { "name": "entity.name.function.rust" }, "2": { "name": "keyword.operator.misc.rust" } } }, { "begin": "\\b(fn)\\s+([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)", "end": "[\\{;]", "patterns": [ { "include": "#block_comment" }, { "include": "#line_comment" }, { "include": "#sigils" }, { "include": "#self" }, { "include": "#mut" }, { "include": "#ref_lifetime" }, { "include": "#core_types" }, { "include": "#core_marker" }, { "include": "#core_traits" }, { "include": "#std_types" }, { "include": "#std_traits" }, { "include": "#type_params" }, { "include": "#const" }, { "include": "#where" }, { "include": "#unsafe" }, { "name": "keyword.other.fn.rust", "match": "\u0008fn\u0008" } ], "beginCaptures": { "1": { "name": "keyword.other.fn.rust" }, "2": { "name": "entity.name.function.rust" } } }, { "begin": "\\b(enum|struct|trait|union)\\s+([a-zA-Z_][a-zA-Z0-9_]*)", "end": "[\\{\\(;]", "patterns": [ { "include": "#block_comment" }, { "include": "#line_comment" }, { "include": "#core_traits" }, { "include": "#std_traits" }, { "include": "#type_params" }, { "include": "#core_types" }, { "include": "#pub" }, { "include": "#where" } ], "beginCaptures": { "1": { "name": "storage.type.rust" }, "2": { "name": "entity.name.type.rust" } } }, { "begin": "\\b(type)\\s+([a-zA-Z_][a-zA-Z0-9_]*)", "end": ";", "patterns": [ { "include": "#block_comment" }, { "include": "#line_comment" }, { "include": "#sigils" }, { "include": "#mut" }, { "include": "#lifetime" }, { "include": "#ref_lifetime" }, { "include": "#core_types" }, { "include": "#core_marker" }, { "include": "#core_traits" }, { "include": "#std_types" }, { "include": "#std_traits" }, { "include": "#type_params" } ], "beginCaptures": { "1": { "name": "storage.type.rust" }, "2": { "name": "entity.name.type.rust" } } } ], "repository": { "block_comment": { "name": "comment.block.rust", "begin": "/\\*", "end": "\\*/", "patterns": [ { "include": "#block_doc_comment" }, { "include": "#block_comment" } ] }, "block_doc_comment": { "name": "comment.block.documentation.rust", "begin": "/\\*[\\*!](?![\\*/])", "end": "\\*/", "patterns": [ { "include": "#block_doc_comment" }, { "include": "#block_comment" } ] }, "box": { "name": "storage.modifier.box.rust", "match": "\\bbox\\b" }, "const": { "name": "storage.modifier.const.rust", "match": "\\bconst\\b" }, "core_marker": { "name": "support.type.marker.rust", "match": "\\b(Copy|Send|Sized|Sync)\\b" }, "core_traits": { "name": "support.type.core.rust", "match": "\\b(Drop|Fn|FnMut|FnOnce|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator)\\b" }, "core_types": { "name": "storage.type.core.rust", "match": "\\b(bool|char|usize|isize|u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|f32|f64|str|Self|Option|Result)\\b" }, "core_vars": { "name": "support.constant.core.rust", "match": "\\b(Some|None|Ok|Err)\\b" }, "escaped_character": { "name": "constant.character.escape.rust", "match": "\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)" }, "lifetime": { "name": "storage.modifier.lifetime.rust", "match": "'([a-zA-Z_][a-zA-Z0-9_]*)\\b", "captures": { "1": { "name": "entity.name.lifetime.rust" } } }, "line_comment": { "name": "comment.line.double-slash.rust", "begin": "//", "end": "$" }, "line_doc_comment": { "name": "comment.line.documentation.rust", "begin": "//[!/](?=[^/])", "end": "$" }, "mut": { "name": "storage.modifier.mut.rust", "match": "\\bmut\\b" }, "pub": { "name": "storage.modifier.visibility.rust", "match": "\\bpub\\b" }, "raw_string_literal": { "name": "string.quoted.double.raw.rust", "begin": "b?r(#*)\"", "end": "\"\\1" }, "ref_lifetime": { "match": "\u0026('([a-zA-Z_][a-zA-Z0-9_]*))\\b", "captures": { "1": { "name": "storage.modifier.lifetime.rust" }, "2": { "name": "entity.name.lifetime.rust" } } }, "self": { "name": "variable.language.rust", "match": "\\bself\\b" }, "sigils": { "name": "keyword.operator.sigil.rust", "match": "[\u0026*](?=[a-zA-Z0-9_\\(\\[\\|\\\"]+)" }, "std_traits": { "name": "support.type.std.rust", "match": "\\b(ToOwned|ToString)\\b" }, "std_types": { "name": "storage.class.std.rust", "match": "\\b(Box|String|Vec|Path|PathBuf)\\b" }, "string_literal": { "name": "string.quoted.double.rust", "begin": "b?\"", "end": "\"", "patterns": [ { "include": "#escaped_character" } ] }, "type": { "name": "entity.name.type.rust", "match": "\\b([A-Za-z][_A-Za-z0-9]*|_[_A-Za-z0-9]+)\\b" }, "type_params": { "name": "meta.type_params.rust", "begin": "\u003c(?![=\u003c])", "end": "(?\u003c![-])\u003e", "patterns": [ { "include": "#block_comment" }, { "include": "#line_comment" }, { "include": "#sigils" }, { "include": "#mut" }, { "include": "#lifetime" }, { "include": "#core_types" }, { "include": "#core_marker" }, { "include": "#core_traits" }, { "include": "#std_types" }, { "include": "#std_traits" }, { "include": "#type_params" } ] }, "unsafe": { "name": "keyword.other.unsafe.rust", "match": "\\bunsafe\\b" }, "where": { "name": "keyword.other.where.rust", "match": "\\bwhere\\b" } } }