@@ -63,7 +63,7 @@ pub fn highlight_text(st string, file_path string, commit bool) (string, int, in
63
63
if in_comment {
64
64
res << '<i>' .bytes ()
65
65
}
66
- if ! in_comment && ! in_line_comment && runes[pos + 1 ] != ' \n ' . bytes ()[ 0 ] {
66
+ if ! in_comment && ! in_line_comment && runes[pos + 1 ] != ` \n ` {
67
67
sloc++
68
68
}
69
69
continue
@@ -74,7 +74,7 @@ pub fn highlight_text(st string, file_path string, commit bool) (string, int, in
74
74
}
75
75
if in_comment {
76
76
res << write (c)
77
- if c == mlc_end. bytes () [0 ] && is_line_comment (runes, pos, mlc_end) {
77
+ if c == mlc_end[0 ] && is_line_comment (runes, pos, mlc_end) {
78
78
in_comment = false
79
79
res << runes[pos + 1 ]
80
80
pos++
@@ -88,7 +88,7 @@ pub fn highlight_text(st string, file_path string, commit bool) (string, int, in
88
88
}
89
89
if in_string {
90
90
res << write (c)
91
- if runes[pos - 1 ] == `\\ ` && ss == '"' . bytes ()[ 0 ] {
91
+ if runes[pos - 1 ] == `\\ ` && ss == `"` {
92
92
continue
93
93
}
94
94
if c == ss {
@@ -135,38 +135,38 @@ pub fn highlight_text(st string, file_path string, commit bool) (string, int, in
135
135
return res.bytestr (), lines, sloc
136
136
}
137
137
138
- fn write (c byte ) []u8 {
138
+ fn write (c u8 ) []u8 {
139
139
mut tmp := []u8 {}
140
- if c == '<' . bytes ()[ 0 ] {
140
+ if c == `<` {
141
141
tmp << '<' .bytes ()
142
- } else if c == '>' . bytes ()[ 0 ] {
142
+ } else if c == `>` {
143
143
tmp << '>' .bytes ()
144
144
} else {
145
145
tmp << c
146
146
}
147
147
return tmp
148
148
}
149
149
150
- fn is_letter (c byte , lang Lang) bool {
150
+ fn is_letter (c u8 , lang Lang) bool {
151
151
name := lang.name.to_lower ()
152
- if (name == 'cpp' || name == 'c' || name == 'd' || name == 'swift' ) && c == '#' . bytes ()[ 0 ] {
152
+ if (name == 'cpp' || name == 'c' || name == 'd' || name == 'swift' ) && c == `#` {
153
153
return true
154
154
}
155
155
return c.is_letter () || c == `_`
156
156
}
157
157
158
- fn is_string_token (c byte , lang Lang) bool {
158
+ fn is_string_token (c u8 , lang Lang) bool {
159
159
for val in lang.string_start {
160
- if c == val. bytes () [0 ] {
160
+ if c == val[0 ] {
161
161
return true
162
162
}
163
163
}
164
164
return false
165
165
}
166
166
167
167
fn is_line_comment (s []u8 , pos int , lc string ) bool {
168
- for i in 0 .. lc.len {
169
- if s[pos + i] != lc. bytes ()[i] {
168
+ for i, b in lc {
169
+ if s[pos + i] != b {
170
170
return false
171
171
}
172
172
}
@@ -176,7 +176,7 @@ fn is_line_comment(s []u8, pos int, lc string) bool {
176
176
fn is_single_line (s string ) bool {
177
177
mut cnt := 0
178
178
for i in 0 .. s.len {
179
- if s. bytes () [i] == ' \n ' . bytes ()[ 0 ] {
179
+ if s[i] == ` \n ` {
180
180
cnt++
181
181
if cnt > 1 {
182
182
return false
0 commit comments