|
4 | 4 | <!-- checks are conservative by nature: there are some programs that are actually -->
|
5 | 5 | <!-- safe, but the compiler is not able to verify this is true. To write these kinds -->
|
6 | 6 | <!-- of programs, we need to tell the compiler to relax its restrictions a bit. For -->
|
7 |
| -<!-- this, Rust has a keyword, `unsafe`. Code using `unsafe` has less restrictions --> |
| 7 | +<!-- this, Rust has a keyword, `unsafe`. Code using `unsafe` has fewer restrictions --> |
8 | 8 | <!-- than normal code does. -->
|
9 | 9 | Rustの主たる魅力は、プログラムの動作についての強力で静的な保証です。
|
10 | 10 | しかしながら、安全性検査は本来保守的なものです。
|
@@ -56,8 +56,8 @@ unsafe impl Scary for i32 {}
|
56 | 56 | ```
|
57 | 57 |
|
58 | 58 | <!-- It’s important to be able to explicitly delineate code that may have bugs that -->
|
59 |
| -<!-- cause big problems. If a Rust program segfaults, you can be sure it’s somewhere --> |
60 |
| -<!-- in the sections marked `unsafe`. --> |
| 59 | +<!-- cause big problems. If a Rust program segfaults, you can be sure the cause is --> |
| 60 | +<!-- related to something marked `unsafe`. --> |
61 | 61 | 大きな問題を引き起こすバグがあるかもしれないコードを明示できるのは重要なことです。
|
62 | 62 | もしRustのプログラムがセグメンテーション違反を起こしても、バグは `unsafe` で印付けられた区間のどこかにあると確信できます。
|
63 | 63 |
|
@@ -166,11 +166,11 @@ Rustでバグのあるコードを書くことはできますし、実際に書
|
166 | 166 |
|
167 | 167 | <!-- That’s it. It’s important that `unsafe` does not, for example, ‘turn off the -->
|
168 | 168 | <!-- borrow checker’. Adding `unsafe` to some random Rust code doesn’t change its -->
|
169 |
| -<!-- semantics, it won’t just start accepting anything. But it will let you write --> |
| 169 | +<!-- semantics, it won’t start accepting anything. But it will let you write --> |
170 | 170 | <!-- things that _do_ break some of the rules. -->
|
171 | 171 | 以上です。
|
172 | 172 | 重要なのは、 `unsafe` が、たとえば「借用チェッカをオフにする」といったことを行わないことです。
|
173 |
| -Rustのコードの適当な位置に `unsafe` を加えてもセマンティクスは変わらず、何でもただ受理するようになるということにはなりません。 |
| 173 | +Rustのコードの適当な位置に `unsafe` を加えてもセマンティクスは変わらず、何でも受理するようになるということにはなりません。 |
174 | 174 | それでも、`unsafe` はルールのいくつかを破るコードを書けるようにはするのです。
|
175 | 175 |
|
176 | 176 | <!-- You will also encounter the `unsafe` keyword when writing bindings to foreign -->
|
|
0 commit comments