Skip to content

Commit

Permalink
Merge pull request #193 from chengr4/zh_tw
Browse files Browse the repository at this point in the history
first_word function also works for whole String reference
  • Loading branch information
wusyong authored Dec 28, 2023
2 parents ed7fb63 + 190e615 commit ab76706
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ fn main() {
// first_word 適用於 `String` 的切片,無論是部分或整體
let word = first_word(&my_string[0..6]);
let word = first_word(&my_string[..]);
// first_word 也適用於 `String` 的參考,這等同於對整個 `String` 切片的操作。
let word = first_word(&my_string);

let my_string_literal = "hello world";

Expand Down

0 comments on commit ab76706

Please sign in to comment.