1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
use super::Syntax;
use std::collections::HashSet;
impl Syntax {
#[must_use]
pub fn rust() -> Self {
Syntax {
language: "Rust",
case_sensitive: true,
comment: "//",
comment_multiline: ["/*", "*/"],
keywords: HashSet::from([
"as", "break", "const", "continue", "crate", "else", "enum", "extern", "fn", "for",
"if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref",
"return", "self", "struct", "super", "trait", "type", "use", "where", "while",
"async", "await", "abstract", "become", "box", "do", "final", "macro", "override",
"priv", "typeof", "unsized", "virtual", "yield", "try", "unsafe", "dyn",
]),
types: HashSet::from([
"Option",
"Result",
"Error",
"Box",
"Cow",
// Primitives
"bool",
"i8",
"u8",
"i16",
"u16",
"i32",
"u32",
"i64",
"u64",
"i128",
"u128",
"isize",
"usize",
"f32",
"f64",
"char",
"str",
"String",
// STD Collections
"Vec",
"HashMap",
"HashSet",
"BTreeMap",
"BTreeSet",
"VecDeque",
"BinaryHeap",
"LinkedList",
// RC
"Rc",
"Weak",
"LazyCell",
"SyncUnsafeCell",
"BorrowErrorl",
"BorrowMutErrorl",
"Celll",
"OnceCelll",
"Refl",
"RefCelll",
"RefMutl",
"UnsafeCell",
"Exclusive",
"LazyLock",
// ARC
"Arc",
"Barrier",
"BarrierWaitResult",
"Condvar",
"Mutex",
"MutexGuard",
"Once",
"OnceLock",
"OnceState",
"PoisonError",
"RwLock",
"RwLockReadGuard",
"RwLockWriteGuard",
"WaitTimeoutResult",
"Weak",
]),
special: HashSet::from(["Self", "static", "true", "false"]),
}
}
}