| OLD | NEW |
| 1 /* TODO | 1 /* TODO |
| 2 Add support for Markdown notation inside doc comments | 2 Add support for Markdown notation inside doc comments |
| 3 Add support for nested block comments... | 3 Add support for nested block comments... |
| 4 Match closure params even when not followed by dash or brace | 4 Match closure params even when not followed by dash or brace |
| 5 Add better support for macro definition | 5 Add better support for macro definition |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 Prism.languages.rust = { | 8 Prism.languages.rust = { |
| 9 'comment': [ | 9 'comment': [ |
| 10 { | 10 { |
| 11 pattern: /(^|[^\\])\/\*[\w\W]*?\*\//, | 11 pattern: /(^|[^\\])\/\*[\w\W]*?\*\//, |
| 12 lookbehind: true | 12 lookbehind: true |
| 13 }, | 13 }, |
| 14 { | 14 { |
| 15 » » » pattern: /(^|[^\\:])\/\/.*?(\r?\n|$)/, | 15 » » » pattern: /(^|[^\\:])\/\/.*/, |
| 16 lookbehind: true | 16 lookbehind: true |
| 17 } | 17 } |
| 18 ], | 18 ], |
| 19 'string': [ | 19 'string': [ |
| 20 /b?r(#*)"(?:\\?.)*?"\1/, | 20 /b?r(#*)"(?:\\?.)*?"\1/, |
| 21 /b?("|')(?:\\?.)*?\1/ | 21 /b?("|')(?:\\?.)*?\1/ |
| 22 ], | 22 ], |
| 23 'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|d
o|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|off
setof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|tru
e|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, | 23 'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|d
o|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|off
setof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|tru
e|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, |
| 24 | 24 |
| 25 'attribute': { | 25 'attribute': { |
| 26 pattern: /#!?\[.+?\]/, | 26 pattern: /#!?\[.+?\]/, |
| 27 alias: 'attr-name' | 27 alias: 'attr-name' |
| 28 }, | 28 }, |
| 29 | 29 |
| 30 'function': [ | 30 'function': [ |
| 31 /[a-z0-9_]+(?=\s*\()/i, | 31 /[a-z0-9_]+(?=\s*\()/i, |
| 32 // Macros can use parens or brackets | 32 // Macros can use parens or brackets |
| 33 /[a-z0-9_]+!(?=\s*\(|\[)/i | 33 /[a-z0-9_]+!(?=\s*\(|\[)/i |
| 34 ], | 34 ], |
| 35 'macro-rules': { | 35 'macro-rules': { |
| 36 pattern: /[a-z0-9_]+!/i, | 36 pattern: /[a-z0-9_]+!/i, |
| 37 alias: 'function' | 37 alias: 'function' |
| 38 }, | 38 }, |
| 39 | 39 |
| 40 // Hex, oct, bin, dec numbers with visual separators and type suffix | 40 // Hex, oct, bin, dec numbers with visual separators and type suffix |
| 41 » 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[0
1](?:_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32)?|f
32|f64))?\b/, | 41 » 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[0
1](?:_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)
?|f32|f64))?\b/, |
| 42 | 42 |
| 43 // Closure params should not be confused with bitwise OR | | 43 // Closure params should not be confused with bitwise OR | |
| 44 'closure-params': { | 44 'closure-params': { |
| 45 pattern: /\|[^|]*\|(?=\s*[{-])/, | 45 pattern: /\|[^|]*\|(?=\s*[{-])/, |
| 46 inside: { | 46 inside: { |
| 47 'punctuation': /[\|:,]/, | 47 'punctuation': /[\|:,]/, |
| 48 'operator': /[&*]/ | 48 'operator': /[&*]/ |
| 49 } | 49 } |
| 50 }, | 50 }, |
| 51 » 'punctuation': /[{}[\];(),.:]|->/, | 51 » 'punctuation': /[{}[\];(),:]|\.+|->/, |
| 52 » 'operator': /[-+]{1,2}|!=?|<=?|>=?|={1,3}|&&?|\|\|?|\*|\/|\^|%|<<|>>@/ | 52 » 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/ |
| 53 }; | 53 }; |
| OLD | NEW |