4.1.
What is Ownership?
The main purpose of ownership is to manage heap data.
4.2.
References and Borrowing
At any given time, you can have
either
one mutable reference
or
any number of immutable references.
References must always be valid.
4.3.
The Slice Type
String literals are string slices of type
&str
.
Defining a function to take a string slice instead of a reference to a
String
makes our API more general and useful without losing any functionality. We can pass a
String
to a function accepting
&str
thanks to
deref coercions
.