|
|
|
|
|
by carlmr
140 days ago
|
|
>In particular, an error on one line may force you to change a large part of your code. There's a simple trick to avoid that, use `.clone()` more and use fewer references. In C++ you would be probably copying around even more data unnecessarily before optimization. In Rust everything is move by default. A few clones here and there can obviate the need to think about lifetimes everywhere and put you roughly on par with normal C++. You can still optimize later when you solved the problem. |
|
Another option is to just use cells and treat the execution model similarly to JavaScript where mutation is limited specific scopes.