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

tools: format most examples and tutorials, add them to v test-cleancode (#9826)

This commit is contained in:
Lukas Neubert
2021-04-20 16:16:35 +02:00
committed by GitHub
parent dff50686d6
commit 16e79bc3ca
38 changed files with 471 additions and 433 deletions

View File

@ -300,7 +300,7 @@ fn (mut b Buffer) free() {
eprintln(@MOD + '.' + @STRUCT + '::' + @FN)
}
for line in b.lines {
unsafe {line.free()}
unsafe { line.free() }
}
unsafe { b.lines.free() }
}
@ -374,12 +374,12 @@ fn (mut b Buffer) move_to_word(movement Movement) {
}
// first, move past all non-`a-zA-Z0-9_` characters
for x + a >= 0 && x + a < line.len && !(line[x + a].is_letter()
|| line[x + a].is_digit()|| line[x + a] == `_`) {
|| line[x + a].is_digit() || line[x + a] == `_`) {
x += a
}
// then, move past all the letters and numbers
for x + a >= 0 && x + a < line.len && (line[x + a].is_letter()
|| line[x + a].is_digit()|| line[x + a] == `_`) {
|| line[x + a].is_digit() || line[x + a] == `_`) {
x += a
}
// if the cursor is out of bounds, move it to the next/previous line
@ -393,19 +393,11 @@ fn (mut b Buffer) move_to_word(movement Movement) {
}
fn imax(x int, y int) int {
return if x < y {
y
} else {
x
}
return if x < y { y } else { x }
}
fn imin(x int, y int) int {
return if x < y {
x
} else {
y
}
return if x < y { x } else { y }
}
struct Cursor {

View File

@ -396,7 +396,7 @@ fn (a App) check_capture() bool {
snake_pos := a.snake.get_head().pos
rat_pos := a.rat.pos
return snake_pos.x <= rat_pos.x + block_size && snake_pos.x + block_size >= rat_pos.x
&& snake_pos.y <= rat_pos.y + block_size&& snake_pos.y + block_size >= rat_pos.y
&& snake_pos.y <= rat_pos.y + block_size && snake_pos.y + block_size >= rat_pos.y
}
fn (mut a App) draw_snake() {