1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: single line ternary return (#8605)

This commit is contained in:
Lukas Neubert
2021-02-08 00:28:46 +01:00
committed by GitHub
parent 118ca1240e
commit 473cd1d416
13 changed files with 49 additions and 79 deletions

View File

@@ -29,31 +29,19 @@ pub fn can_show_color_on_stderr() bool {
// ok_message returns a colored string with green color.
// If colors are not allowed, returns a given string.
pub fn ok_message(s string) string {
return if can_show_color_on_stdout() {
green(' $s ')
} else {
s
}
return if can_show_color_on_stdout() { green(' $s ') } else { s }
}
// fail_message returns a colored string with red color.
// If colors are not allowed, returns a given string.
pub fn fail_message(s string) string {
return if can_show_color_on_stdout() {
inverse(bg_white(bold(red(' $s '))))
} else {
s
}
return if can_show_color_on_stdout() { inverse(bg_white(bold(red(' $s ')))) } else { s }
}
// warn_message returns a colored string with yellow color.
// If colors are not allowed, returns a given string.
pub fn warn_message(s string) string {
return if can_show_color_on_stdout() {
bright_yellow(' $s ')
} else {
s
}
return if can_show_color_on_stdout() { bright_yellow(' $s ') } else { s }
}
// colorize returns a colored string by running the specified `cfn` over
@@ -107,11 +95,7 @@ pub fn header(text string, divider string) string {
}
fn imax(x int, y int) int {
return if x > y {
x
} else {
y
}
return if x > y { x } else { y }
}
fn supports_escape_sequences(fd int) bool {