@@ -158,9 +158,9 @@ fn add(self, s: &str) -> String {
158
158
This isn’t the exact signature that’s in the standard library; there ` add ` is
159
159
defined using generics. Here, we’re looking at the signature of ` add ` with
160
160
concrete types substituted for the generic ones, which is what happens when we
161
- call this method with ` String ` values. We'll be discussing generics in Chapter
162
- 10 . This signature gives us the clues we need to understand the tricky bits of
163
- the ` + ` operator.
161
+ call this method with ` String ` values. We'll be discussing generics in
162
+ Chapter 10. This signature gives us the clues we need to understand the tricky
163
+ bits of the ` + ` operator.
164
164
165
165
First of all, ` s2 ` has an ` & ` , meaning that we are adding a * reference* of the
166
166
second string to the first string. This is because of the ` s ` parameter in the
@@ -250,8 +250,8 @@ UTF-8. What about this example, though?
250
250
let len = String :: from (" Здравствуйте" ). len ();
251
251
```
252
252
253
- A person asked how long the string is might say 12. However, Rust’s answer is
254
- 24 . This is the number of bytes that it takes to encode “Здравствуйте” in
253
+ A person asked how long the string is might say 12. However, Rust’s answer
254
+ is 24. This is the number of bytes that it takes to encode “Здравствуйте” in
255
255
UTF-8, since each Unicode scalar value takes two bytes of storage. Therefore,
256
256
an index into the string’s bytes will not always correlate to a valid Unicode
257
257
scalar value.
0 commit comments