Current builders in Gunship (e.g. MeshBuilder) consume the builder instance on each mutation. This works fine for chaining but makes non-chained calls a pain:
Builder::new().foo().bar().build();
let builder = Builder::new();
builder.foo();
builder.bar(); // ERROR: `builder` was consumed in the last statement.
builder.build();
This can be fixed by changing the signatures of the methods from foo(self) -> Self to foo(&mut self) -> &mut Self.
Current builders in Gunship (e.g.
MeshBuilder
) consume the builder instance on each mutation. This works fine for chaining but makes non-chained calls a pain:This can be fixed by changing the signatures of the methods from
foo(self) -> Self
tofoo(&mut self) -> &mut Self
.Builders that this needs to be changed for:
MeshBuilder
inlib/polygon-rs
.For more information on the builder pattern in rust see this article: https://aturon.github.io/ownership/builders.html