diff --git a/img/foo1.png b/img/foo1.png index 20c022658..5976fe4a2 100644 Binary files a/img/foo1.png and b/img/foo1.png differ diff --git a/img/foo2.png b/img/foo2.png index 1944aad70..a8cd782fa 100644 Binary files a/img/foo2.png and b/img/foo2.png differ diff --git a/img/foo3.png b/img/foo3.png index 1fdca9fee..895576589 100644 Binary files a/img/foo3.png and b/img/foo3.png differ diff --git a/img/foo4.png b/img/foo4.png index 63e95354a..595f1d6e1 100644 Binary files a/img/foo4.png and b/img/foo4.png differ diff --git a/ownership.html b/ownership.html index ac6214523..161a2b4f4 100644 --- a/ownership.html +++ b/ownership.html @@ -192,7 +192,7 @@ let s2 = s1;
You might say “copy the String!” This is both correct and incorrect at the
same time. It does a shallow copy of the String. What’s that mean? Well,
let’s take a look at what String looks like under the covers:


A String is made up of three parts: a pointer to the memory that holds the
contents of the string, a length, and a capacity. The length is how much memory
the String is currently using. The capacity is the total amount of memory the
@@ -210,9 +210,9 @@ of copying are the same. Many people draw distinctions between ‘shallow
copying’ and ‘deep copying’. We don’t use these terms in Rust. We instead say
that something is ‘moved’ or ‘cloned’. Assignment in Rust causes a ‘move’. In
other words, it looks like this:


Not this:
-

When moving, Rust makes a copy of the data structure itself, the contents of
s1 are copied, but if s1 contains a reference, like it does in this case,
Rust will not copy the things that those references refer to.
We say that s1 was moved into s2. When a value moves, its data is copied,
but the original variable binding is no longer usable. That solves our problem:


With only s2 valid, when it goes out of scope, it will free the memory, and we’re done!
This leads us to the Ownership Rules:
@@ -276,7 +276,7 @@ println!("{}", s1);This will work just fine. Remember our diagram from before? In this case, it is doing this:
-

When you see a call to clone(), you know that some arbitrary code is being
executed, which may be expensive. It’s a visual indicator that something
different is going on here.
You might say “copy the String!” This is both correct and incorrect at the
same time. It does a shallow copy of the String. What’s that mean? Well,
let’s take a look at what String looks like under the covers:


A String is made up of three parts: a pointer to the memory that holds the
contents of the string, a length, and a capacity. The length is how much memory
the String is currently using. The capacity is the total amount of memory the
@@ -2031,9 +2031,9 @@ of copying are the same. Many people draw distinctions between ‘shallow
copying’ and ‘deep copying’. We don’t use these terms in Rust. We instead say
that something is ‘moved’ or ‘cloned’. Assignment in Rust causes a ‘move’. In
other words, it looks like this:


Not this:
-

When moving, Rust makes a copy of the data structure itself, the contents of
s1 are copied, but if s1 contains a reference, like it does in this case,
Rust will not copy the things that those references refer to.
We say that s1 was moved into s2. When a value moves, its data is copied,
but the original variable binding is no longer usable. That solves our problem:


With only s2 valid, when it goes out of scope, it will free the memory, and we’re done!
This leads us to the Ownership Rules:
@@ -2097,7 +2097,7 @@ println!("{}", s1);This will work just fine. Remember our diagram from before? In this case, it is doing this:
-

When you see a call to clone(), you know that some arbitrary code is being
executed, which may be expensive. It’s a visual indicator that something
different is going on here.