rust.min.js 2.8 KB

12345678910111213141516171819202122232425262728
  1. /*! `rust` grammar compiled for Highlight.js 11.7.0 */
  2. var hljsGrammar=(()=>{"use strict";return e=>{const t=e.regex,a={
  3. className:"title.function.invoke",relevance:0,
  4. begin:t.concat(/\b/,/(?!let\b)/,e.IDENT_RE,t.lookahead(/\s*\(/))
  5. },n="([ui](8|16|32|64|128|size)|f(32|64))?",r=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],s=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"]
  6. ;return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:s,
  7. keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","unsafe","unsized","use","virtual","where","while","yield"],
  8. literal:["true","false","Some","None","Ok","Err"],built_in:r},illegal:"</",
  9. contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]
  10. }),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{
  11. className:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{
  12. begin:/b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/}]},{className:"symbol",
  13. begin:/'[a-zA-Z_][a-zA-Z0-9_]*/},{className:"number",variants:[{
  14. begin:"\\b0b([01_]+)"+n},{begin:"\\b0o([0-7_]+)"+n},{
  15. begin:"\\b0x([A-Fa-f0-9_]+)"+n},{
  16. begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+n}],relevance:0},{
  17. begin:[/fn/,/\s+/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",
  18. 3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{
  19. className:"string",begin:/"/,end:/"/}]},{
  20. begin:[/let/,/\s+/,/(?:mut\s+)?/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",
  21. 3:"keyword",4:"variable"}},{
  22. begin:[/for/,/\s+/,e.UNDERSCORE_IDENT_RE,/\s+/,/in/],className:{1:"keyword",
  23. 3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,e.UNDERSCORE_IDENT_RE],
  24. className:{1:"keyword",3:"title.class"}},{
  25. begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,e.UNDERSCORE_IDENT_RE],
  26. className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{
  27. keyword:"Self",built_in:r,type:s}},{className:"punctuation",begin:"->"},a]}}})()
  28. ;export default hljsGrammar;