Ownership: Function Parameters

Overview

Passing a value into a function transfers ownership when the parameter takes the value by type (for example, String rather than &String).

After that call, the original binding is no longer valid unless ownership is returned in some form.

Official Rust Book: Ownership and Functions


Code example