fmt: use the new `mut` syntax in args
parent
b4c93349e8
commit
f80876497e
|
@ -50,10 +50,13 @@ pub fn (node &FnDecl) str(t &table.Table) string {
|
||||||
is_last_arg := i == node.args.len - 1
|
is_last_arg := i == node.args.len - 1
|
||||||
should_add_type := is_last_arg || node.args[i + 1].typ != arg.typ || (node.is_variadic &&
|
should_add_type := is_last_arg || node.args[i + 1].typ != arg.typ || (node.is_variadic &&
|
||||||
i == node.args.len - 2)
|
i == node.args.len - 2)
|
||||||
|
if arg.is_mut {
|
||||||
|
f.write('mut ')
|
||||||
|
}
|
||||||
f.write(arg.name)
|
f.write(arg.name)
|
||||||
mut s := t.type_to_str(arg.typ)
|
mut s := t.type_to_str(arg.typ)
|
||||||
if arg.is_mut {
|
if arg.is_mut {
|
||||||
f.write(' mut')
|
// f.write(' mut')
|
||||||
if s.starts_with('&') {
|
if s.starts_with('&') {
|
||||||
s = s[1..]
|
s = s[1..]
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,10 @@ fn (f Foo) fn_with_optional() ?int {
|
||||||
return 40
|
return 40
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mut_array(mut a []int) {
|
||||||
|
println(1)
|
||||||
|
}
|
||||||
|
|
||||||
fn fn_with_ref_return() &Foo {
|
fn fn_with_ref_return() &Foo {
|
||||||
return &Foo{}
|
return &Foo{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,10 @@ fn (f Foo) fn_with_optional() ?int {
|
||||||
return 40
|
return 40
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mut_array(a mut []int) {
|
||||||
|
println(1)
|
||||||
|
}
|
||||||
|
|
||||||
fn fn_with_ref_return() &Foo {
|
fn fn_with_ref_return() &Foo {
|
||||||
return &Foo{}
|
return &Foo{}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue