1
+
2
+ < style >
3
+ body { margin : 0 ; }
4
+ pre { color : # DCDCCC ; background : # 3F3F3F ; font-size : 22px ; padding : 0.4em ; }
5
+
6
+ .lifetime { color : # DFAF8F ; font-style : italic; }
7
+ .label { color : # DFAF8F ; font-style : italic; }
8
+ .comment { color : # 7F9F7F ; }
9
+ .documentation { color : # 629755 ; }
10
+ .intra_doc_link { font-style : italic; }
11
+ .injected { opacity : 0.65 ; }
12
+ .struct , .enum { color : # 7CB8BB ; }
13
+ .enum_variant { color : # BDE0F3 ; }
14
+ .string_literal { color : # CC9393 ; }
15
+ .field { color : # 94BFF3 ; }
16
+ .function { color : # 93E0E3 ; }
17
+ .function .unsafe { color : # BC8383 ; }
18
+ .operator .unsafe { color : # BC8383 ; }
19
+ .parameter { color : # 94BFF3 ; }
20
+ .text { color : # DCDCCC ; }
21
+ .type { color : # 7CB8BB ; }
22
+ .builtin_type { color : # 8CD0D3 ; }
23
+ .type_param { color : # DFAF8F ; }
24
+ .attribute { color : # 94BFF3 ; }
25
+ .numeric_literal { color : # BFEBBF ; }
26
+ .bool_literal { color : # BFE6EB ; }
27
+ .macro { color : # 94BFF3 ; }
28
+ .module { color : # AFD8AF ; }
29
+ .value_param { color : # DCDCCC ; }
30
+ .variable { color : # DCDCCC ; }
31
+ .format_specifier { color : # CC696B ; }
32
+ .mutable { text-decoration : underline; }
33
+ .escape_sequence { color : # 94BFF3 ; }
34
+ .keyword { color : # F0DFAF ; font-weight : bold; }
35
+ .keyword .unsafe { color : # BC8383 ; font-weight : bold; }
36
+ .control { font-style : italic; }
37
+
38
+ .unresolved_reference { color : # FC5555 ; text-decoration : wavy underline; }
39
+ </ style >
40
+ < pre > < code > < span class ="keyword "> struct</ span > < span class ="struct declaration "> Cat</ span > < span class ="semicolon "> ;</ span >
41
+
42
+ < span class ="keyword "> trait</ span > < span class ="trait declaration "> Animal</ span > < span class ="brace "> {</ span >
43
+ < span class ="keyword "> const</ span > < span class ="constant declaration associated trait "> SOUND</ span > < span class ="colon "> :</ span > < span class ="operator "> &</ span > < span class ="lifetime "> 'static</ span > < span class ="builtin_type "> str</ span > < span class ="semicolon "> ;</ span >
44
+
45
+ < span class ="keyword "> fn</ span > < span class ="function declaration associated trait "> make_sound</ span > < span class ="parenthesis "> (</ span > < span class ="operator "> &</ span > < span class ="self_keyword declaration "> self</ span > < span class ="parenthesis "> )</ span > < span class ="brace "> {</ span >
46
+ < span class ="macro "> println!</ span > < span class ="parenthesis "> (</ span > < span class ="string_literal "> "{}"</ span > < span class ="comma "> ,</ span > Self< span class ="colon "> :</ span > < span class ="colon "> :</ span > SOUND< span class ="parenthesis "> )</ span > < span class ="semicolon "> ;</ span >
47
+ < span class ="brace "> }</ span >
48
+ < span class ="brace "> }</ span >
49
+
50
+ < span class ="keyword "> impl</ span > < span class ="trait "> Animal</ span > < span class ="keyword "> for</ span > < span class ="struct "> Cat</ span > < span class ="brace "> {</ span >
51
+ < span class ="keyword "> const</ span > < span class ="constant declaration associated trait "> SOUND</ span > < span class ="colon "> :</ span > < span class ="operator "> &</ span > < span class ="lifetime "> 'static</ span > < span class ="builtin_type "> str</ span > < span class ="operator "> =</ span > < span class ="string_literal "> "Meow!"</ span > < span class ="semicolon "> ;</ span >
52
+ < span class ="brace "> }</ span >
53
+
54
+ < span class ="keyword "> impl</ span > < span class ="struct "> Cat</ span > < span class ="brace "> {</ span >
55
+ < span class ="keyword "> const</ span > < span class ="constant declaration associated "> SPEED</ span > < span class ="colon "> :</ span > < span class ="builtin_type "> u32</ span > < span class ="operator "> =</ span > < span class ="numeric_literal "> 2</ span > < span class ="semicolon "> ;</ span >
56
+
57
+ < span class ="keyword "> fn</ span > < span class ="function declaration static associated "> run</ span > < span class ="parenthesis "> (</ span > < span class ="parenthesis "> )</ span > < span class ="brace "> {</ span > < span class ="brace "> }</ span >
58
+ < span class ="brace "> }</ span >
59
+
60
+ < span class ="keyword "> fn</ span > < span class ="function declaration "> main</ span > < span class ="parenthesis "> (</ span > < span class ="parenthesis "> )</ span > < span class ="brace "> {</ span >
61
+ < span class ="keyword "> let</ span > < span class ="variable declaration "> cat</ span > < span class ="operator "> =</ span > < span class ="struct "> Cat</ span > < span class ="semicolon "> ;</ span >
62
+ < span class ="variable "> cat</ span > < span class ="operator "> .</ span > < span class ="function associated trait "> make_sound</ span > < span class ="parenthesis "> (</ span > < span class ="parenthesis "> )</ span > < span class ="semicolon "> ;</ span >
63
+ < span class ="keyword "> let</ span > < span class ="variable declaration "> _sound</ span > < span class ="operator "> =</ span > < span class ="struct "> Cat</ span > < span class ="operator "> ::</ span > < span class ="constant associated trait "> SOUND</ span > < span class ="semicolon "> ;</ span >
64
+ < span class ="keyword "> let</ span > < span class ="variable declaration "> _speed</ span > < span class ="operator "> =</ span > < span class ="struct "> Cat</ span > < span class ="operator "> ::</ span > < span class ="constant associated "> SPEED</ span > < span class ="semicolon "> ;</ span >
65
+ < span class ="struct "> Cat</ span > < span class ="operator "> ::</ span > < span class ="function static associated "> run</ span > < span class ="parenthesis "> (</ span > < span class ="parenthesis "> )</ span > < span class ="semicolon "> ;</ span >
66
+ < span class ="brace "> }</ span >
67
+ </ code > </ pre >
0 commit comments