File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,12 @@ slices, to understand the problem that slices will solve:
1616fn first_word(s: &String) -> ?
1717```
1818
19- The first_word function has a &String as a parameter. We don’t need ownership, so this is fine.
20- (In idiomatic Rust, functions do not take ownership of their arguments unless they need to,
21- and the reasons for that will become clear as we keep going!)
22- But what should we return? We don’t really have a way to talk about part of a string.
23- However, we could return the index of the end of the word, indicated by a space.
24- Let’s try that, as shown in Listing 4-7.
19+ The ` first_word ` function has a ` &String ` as a parameter. We don’t need
20+ ownership, so this is fine. (In idiomatic Rust, functions do not take ownership
21+ of their arguments unless they need to, and the reasons for that will become
22+ clear as we keep going!) But what should we return? We don’t really have a way
23+ to talk about part of a string. However, we could return the index of the end of
24+ the word, indicated by a space. Let’s try that, as shown in Listing 4-7.
2525
2626<Listing number =" 4-7 " file-name =" src/main.rs " caption =" The `first_word` function that returns a byte index value into the `String` parameter " >
2727
You can’t perform that action at this time.
0 commit comments