File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,28 +14,32 @@ pub mut:
1414 y int
1515}
1616
17- __global can_show_color_on_stdout_cache = ? bool ( none )
18- __global can_show_color_on_stderr_cache = ? bool ( none )
17+ __global can_show_color_on_stdout_cache = 0
18+ __global can_show_color_on_stderr_cache = 0
1919
2020// can_show_color_on_stdout returns true, if colors are allowed in stdout.
2121// It returns false otherwise.
2222pub fn can_show_color_on_stdout () bool {
23- if status := can_show_color_on_stdout_cache {
24- return status
23+ match can_show_color_on_stdout_cache {
24+ 1 { return true }
25+ - 1 { return false }
26+ else {}
2527 }
2628 status := supports_escape_sequences (1 )
27- can_show_color_on_stdout_cache = status
29+ can_show_color_on_stdout_cache = if status { 1 } else { - 1 }
2830 return status
2931}
3032
3133// can_show_color_on_stderr returns true, if colors are allowed in stderr.
3234// It returns false otherwise.
3335pub fn can_show_color_on_stderr () bool {
34- if status := can_show_color_on_stderr_cache {
35- return status
36+ match can_show_color_on_stderr_cache {
37+ 1 { return true }
38+ - 1 { return false }
39+ else {}
3640 }
3741 status := supports_escape_sequences (2 )
38- can_show_color_on_stderr_cache = status
42+ can_show_color_on_stderr_cache = if status { 1 } else { - 1 }
3943 return status
4044}
4145
You can’t perform that action at this time.
0 commit comments