egui_code_editor/syntax/
rust.rs

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