A D vs. Rust example

Stefan Hertenberger SHertenberger at Web.de
Sun Oct 23 11:18:34 UTC 2022


I guess, it really depends on what happens in bar and baz but my 
solution would be  something like this.

```rust
fn main() {
     #[allow(unused_assignments)]
     let mut foo = 5;
     let bar = || -> i32 {
         // do something here
         17
     };
     let baz = || -> i32 {
         // do something here
         42
     };
     foo = bar();
     println!("{}", foo);
     foo = baz();
     println!("{}", foo);

}
```
As always one uses the best fitting tool to solve the problem and 
in your case it was D ?!


More information about the Digitalmars-d mailing list