Skip to content

[Fix] 4.17. String #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 1.6/ja/book/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ println!("The first letter of s is {}", s[0]); // エラー!!!
<!-- expensive operation, and we don’t want to be misleading. Furthermore, ‘letter’ -->
<!-- isn’t something defined in Unicode, exactly. We can choose to look at a string as -->
<!-- individual bytes, or as codepoints:-->
普通、ベクターへの `[]` を用いたアクセスはとても高速です。
普通、ベクタへの `[]` を用いたアクセスはとても高速です。
しかし、UTF-8にエンコードされた文字列中の一つ一つの文字は複数のバイトであることが可能なため、
文字列のn番の文字を探すためには文字列上を移動していく必要があります。
そのような作業はとても高コストな演算であり、誤解してはならない点です。
さらに言えば、「文字」というものはUnicodeにおいては正確に定義されていません。
文字列を、それぞれのバイトとして見ることも、コードポインの集まりとして見ることもできるのです
文字列を、それぞれのバイトとして見ることも、コードポイントの集まりとして見ることもできるのです

```rust
let hachiko = "忠犬ハチ公";
Expand Down Expand Up @@ -177,7 +177,7 @@ println!("");

```rust
# let hachiko = "忠犬ハチ公";
let dog = hachiko.chars().nth(1); // kinda like hachiko[1]
let dog = hachiko.chars().nth(1); // hachiko[1]のような感じで
```

<!-- This emphasizes that we have to walk from the beginning of the list of `chars`. -->
Expand Down