The Rust Programming Language
The issue with the tuple code in Listing 4-5 is that we have to return the String to the calling function so we can still use the String after the call to calculate_length, because the String was moved into calculate_length.
References and Borrowing - The Rust Programming Language Keyboard shortcuts Press ← or → to navigate between chapters Press S or / to search in the book Press ? to show this help Press Esc to hide this help Auto Light Rust Coal Navy Ayu The Rust Programming Language References and Borrowing The issue with the tuple code in Listing 4-5 is that we have to return the String to the calling function so that we can still use the String after the call to calculate_length , because the String was moved into calculate_length . Instead, we can provide a reference to the String value. A reference is like
Explore this link on the map →saved by
related reading
- The Slice Type - The Rust Programming Languagedoc.rust-lang.org
- What is Ownership? - The Rust Programming Languagedoc.rust-lang.org
- A half-hour to learn Rustfasterthanli.me
- Validating References with Lifetimes - The Rust Programming Languagedoc.rust-lang.org
- References and Borrowing - The Rust Programming Languagerust-book.cs.brown.edu
- Rust Language Cheat Sheetcheats.rs
- Variables and Mutability - The Rust Programming Languagedoc.rust-lang.org
- Storing Lists of Values with Vectors - The Rust Programming Languagedoc.rust-lang.org
- Defining and Instantiating Structs - The Rust Programming Languagedoc.rust-lang.org
- Generic Types, Traits, and Lifetimes - The Rust Programming Languagedoc.rust-lang.org
- Defining an Enum - The Rust Programming Languagedoc.rust-lang.org
- Generic Data Types - The Rust Programming Languagedoc.rust-lang.org