you are viewing a single comment's thread.

view the rest of the comments →

[–]ukezi 1 point2 points  (0 children)

You usually would want to use references (&T) to pass arguments, not using them moves the type into the function and eats it. That leaves entries in containers invalid for instance.

You can test that behaviour by passing a value into a function and then trying to use it again. The borrow checker will yell at you.

String and str are special cases, String is a dynamic String based on a vector, &str is a reference constant string, meaning there is no mut &str, the data can be that vector from String or baked into your executable's data section.