3 ms·
This is something Rust is well-suited for (and it's a popular pattern in the Rust community as a result) Rust can a) enforce that a method is non-mutating on i
by brundolf 5y ago
This is something Rust is well-suited for (and it's a popular pattern in the Rust community as a result)
Rust can a) enforce that a method is non-mutating on its object, and b) use move-semantics to return a "new" value without doing an actual clone, while preventing the "old" value from being reused elsewhere. So the immutable "builder" pattern works very smoothly and safely