A D vs. Rust example
Jack Applegame
japplegame at gmail.com
Fri Oct 21 09:15:10 UTC 2022
On Friday, 21 October 2022 at 07:37:41 UTC, Stefan Hertenberger
wrote:
> You don't need to reorder, just use references
>
> ```rust
> fn main() {
> let mut foo = 5;
> let bar = |val: &mut i32| {
> *val = 17;
> };
> let baz = |val: &mut i32| {
> *val = 42;
> };
> bar(&mut foo);
> println!("{}", &mut foo);
> baz(&mut foo);
> println!("{}", &mut foo);
>
> }
> ```
Heh. You don't need closures, just use regular functions.
More information about the Digitalmars-d
mailing list