diff --git a/dot/foo1.dot b/dot/trpl04-01.dot similarity index 100% rename from dot/foo1.dot rename to dot/trpl04-01.dot diff --git a/dot/foo2.dot b/dot/trpl04-02.dot similarity index 100% rename from dot/foo2.dot rename to dot/trpl04-02.dot diff --git a/dot/foo4.dot b/dot/trpl04-03.dot similarity index 100% rename from dot/foo4.dot rename to dot/trpl04-03.dot diff --git a/dot/foo3.dot b/dot/trpl04-04.dot similarity index 100% rename from dot/foo3.dot rename to dot/trpl04-04.dot diff --git a/src/ch04-01-ownership.md b/src/ch04-01-ownership.md index 020ca2b..de9d336 100644 --- a/src/ch04-01-ownership.md +++ b/src/ch04-01-ownership.md @@ -167,7 +167,7 @@ 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: -string +string 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 @@ -180,11 +180,11 @@ When we assign `s1` to `s2`, the `String` itself is copied, meaning we copy the pointer, the length, and the capacity. We do not copy the data that the `String`'s pointer refers to. In other words, it looks like this: -s1 and s2 +s1 and s2 _Not_ this: -s1 and s2 to two places +s1 and s2 to two places There’s a problem here. Both data pointers are pointing to the same place. Why is this a problem? Well, when `s2` goes out of scope, it will free the memory @@ -240,7 +240,7 @@ also invalidates the first binding, instead of calling this a shallow copy, it's called a _move_. Here we would read this by saying that `s1` was _moved_ into `s2`. So what actually happens looks like this: -s1 and s2 to the same place +s1 and s2 to the same place That solves our problem! With only `s2` valid, when it goes out of scope, it alone will free the memory, and we’re done. @@ -279,7 +279,7 @@ println!("{}", s1); This will work just fine. Remember our diagram from before? In this case, it _is_ doing this: -s1 and s2 to two places +s1 and s2 to two places When you see a call to `clone()`, you know that some arbitrary code is being executed, and that code may be expensive. It’s a visual indicator that something diff --git a/src/img/foo1.png b/src/img/trpl04-01.png similarity index 100% rename from src/img/foo1.png rename to src/img/trpl04-01.png diff --git a/src/img/foo2.png b/src/img/trpl04-02.png similarity index 100% rename from src/img/foo2.png rename to src/img/trpl04-02.png diff --git a/src/img/foo4.png b/src/img/trpl04-03.png similarity index 100% rename from src/img/foo4.png rename to src/img/trpl04-03.png diff --git a/src/img/foo3.png b/src/img/trpl04-04.png similarity index 100% rename from src/img/foo3.png rename to src/img/trpl04-04.png