Take parameters to trait functions as mut
authorMatt Corallo <git@bluematt.me>
Thu, 29 Apr 2021 22:49:40 +0000 (22:49 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 30 Apr 2021 04:35:57 +0000 (04:35 +0000)
In keeping with "generally, make all variables mut so that
converters can assume inputs are mut", we should do the same for
trait implementation blocks.

c-bindings-gen/src/main.rs

index 918a05a935e0c117d93f3dddfcb92365a178a78a..fe3746c041bcd247c7c5b9de96140af462b4a250 100644 (file)
@@ -388,7 +388,7 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                                                                                                        ident.mutability.is_some() || ident.subpat.is_some() {
                                                                                                unimplemented!();
                                                                                        }
-                                                                                       write!(w, ", {}{}: ", if $type_resolver.skip_arg(&*arg.ty, Some(&meth_gen_types)) { "_" } else { "" }, ident.ident).unwrap();
+                                                                                       write!(w, ", mut {}{}: ", if $type_resolver.skip_arg(&*arg.ty, Some(&meth_gen_types)) { "_" } else { "" }, ident.ident).unwrap();
                                                                                }
                                                                                _ => unimplemented!(),
                                                                        }