fmt: add a space after + operator/method overload (#7453)
parent
74f7a1a549
commit
304aafdc50
|
@ -3074,11 +3074,11 @@ fn (a Vec) str() string {
|
||||||
return '{$a.x, $a.y}'
|
return '{$a.x, $a.y}'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (a Vec) +(b Vec) Vec {
|
fn (a Vec) + (b Vec) Vec {
|
||||||
return Vec{a.x + b.x, a.y + b.y}
|
return Vec{a.x + b.x, a.y + b.y}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (a Vec) -(b Vec) Vec {
|
fn (a Vec) - (b Vec) Vec {
|
||||||
return Vec{a.x - b.x, a.y - b.y}
|
return Vec{a.x - b.x, a.y - b.y}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub fn (t1 Time) ge(t2 Time) bool {
|
||||||
|
|
||||||
// Time subtract using eperator overloading
|
// Time subtract using eperator overloading
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (lhs Time) -(rhs Time) Duration {
|
pub fn (lhs Time) - (rhs Time) Duration {
|
||||||
lhs_micro := lhs.unix * 1000 * 1000 + u64(lhs.microsecond)
|
lhs_micro := lhs.unix * 1000 * 1000 + u64(lhs.microsecond)
|
||||||
rhs_micro := rhs.unix * 1000 * 1000 + u64(rhs.microsecond)
|
rhs_micro := rhs.unix * 1000 * 1000 + u64(rhs.microsecond)
|
||||||
return (i64(lhs_micro) - i64(rhs_micro)) * microsecond
|
return (i64(lhs_micro) - i64(rhs_micro)) * microsecond
|
||||||
|
|
|
@ -50,6 +50,9 @@ pub fn (node &FnDecl) stringify(t &table.Table, cur_mod string) string {
|
||||||
name = 'JS.$name'
|
name = 'JS.$name'
|
||||||
}
|
}
|
||||||
f.write('fn $receiver$name')
|
f.write('fn $receiver$name')
|
||||||
|
if name in ['+', '-', '*', '/', '%'] {
|
||||||
|
f.write(' ')
|
||||||
|
}
|
||||||
if node.is_generic {
|
if node.is_generic {
|
||||||
f.write('<T>')
|
f.write('<T>')
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ mut:
|
||||||
y int
|
y int
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (a Point) +(b Point) int {
|
pub fn (a Point) + (b Point) int {
|
||||||
return a.x + b.x
|
return a.x + b.x
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
struct Foo {
|
||||||
|
x int
|
||||||
|
}
|
||||||
|
|
||||||
|
fn (a Foo) + (b Foo) Foo {
|
||||||
|
return Foo{a.x + b.x}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn (a Foo) % (b Foo) Foo {
|
||||||
|
return Foo{a.x % b.x}
|
||||||
|
}
|
Loading…
Reference in New Issue