hd-lang

Tour · 2 of 25

A struct is a value, so a function changes yours only if you hand it over with &mut

:= binds a name that cannot be reassigned, let declares a variable that can be reassigned as a whole, and let mut also lets its fields change in place. A struct is a value: before := order is a copy, and a parameter order: Order is the function's own copy, so receipt cannot change yours however it is written. A function that should change the caller's order says so in its signature, order: &mut Order, and the caller says so again at the call, &mut order, which needs a let mut variable. To find every place an order can change, search for &mut.

Run: Ctrl+Enter · Pages: Alt+← Alt+→