Skip to content

Commit 88753c7

Browse files
committed
規約に則した空行の削除
1 parent e0690b1 commit 88753c7

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

1.6/ja/book/unsafe.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ of programs, we need to tell the compiler to relax its restrictions a bit. For
88
this, Rust has a keyword, `unsafe`. Code using `unsafe` has less restrictions
99
than normal code does.
1010
-->
11-
1211
Rustの主たる魅力は、プログラムの動作についての強力で静的な保証です。
1312
しかしながら、安全性検査は本来保守的なものです。
1413
すなわち、実際には安全なのに、そのことがコンパイラには検証できないプログラムがいくらか存在します。
@@ -20,7 +19,6 @@ Rustの主たる魅力は、プログラムの動作についての強力で静
2019
Let’s go over the syntax, and then we’ll talk semantics. `unsafe` is used in
2120
four contexts. The first one is to mark a function as unsafe:
2221
-->
23-
2422
まずシンタックスをみて、それからセマンティクスについて話しましょう。
2523
`unsafe` は4つの場面で使われます。
2624
1つめは、関数がアンセーフであることを印付ける場合です。
@@ -36,7 +34,6 @@ unsafe fn danger_will_robinson() {
3634
All functions called from [FFI][ffi] must be marked as `unsafe`, for example.
3735
The second use of `unsafe` is an unsafe block:
3836
-->
39-
4037
たとえば、[FFI][ffi]から呼び出されるすべての関数は`unsafe`で印付けることが必要です。
4138
`unsafe`の2つめの用途は、アンセーフブロックです。
4239

@@ -50,15 +47,13 @@ unsafe {
5047
```
5148

5249
<!--The third is for unsafe traits:-->
53-
5450
3つめは、アンセーフトレイトです。
5551

5652
```rust
5753
unsafe trait Scary { }
5854
```
5955

6056
<!--And the fourth is for `impl`ementing one of those traits:-->
61-
6257
そして、4つめは、そのアンセーフトレイトを実装する場合です。
6358

6459
```rust
@@ -71,7 +66,6 @@ It’s important to be able to explicitly delineate code that may have bugs that
7166
cause big problems. If a Rust program segfaults, you can be sure it’s somewhere
7267
in the sections marked `unsafe`.
7368
-->
74-
7569
大きな問題を引き起こすバグがあるかもしれないコードを明示できるのは重要なことです。
7670
もしRustのプログラムがセグメンテーション違反を起こしても、バグは `unsafe` で印付けられた区間のどこかにあると確信できます。
7771

@@ -83,7 +77,6 @@ Safe, in the context of Rust, means ‘doesn’t do anything unsafe’. It’s a
8377
important to know that there are certain behaviors that are probably not
8478
desirable in your code, but are expressly _not_ unsafe:
8579
-->
86-
8780
Rustの文脈で、安全とは「どのようなアンセーフなこともしない」ことを意味します。
8881

8982
> 訳注:
@@ -110,7 +103,6 @@ Rust cannot prevent all kinds of software problems. Buggy code can and will be
110103
written in Rust. These things aren’t great, but they don’t qualify as `unsafe`
111104
specifically.
112105
-->
113-
114106
Rustはソフトウェアが抱えるすべての種類の問題を防げるわけではありません。
115107
Rustでバグのあるコードを書くことはできますし、実際に書かれるでしょう。
116108
これらの動作は良いことではありませんが、特にアンセーフだとは見なされません。
@@ -119,7 +111,6 @@ Rustでバグのあるコードを書くことはできますし、実際に書
119111
In addition, the following are all undefined behaviors in Rust, and must be
120112
avoided, even when writing `unsafe` code:
121113
-->
122-
123114
さらに、Rustにおいては、次のものは未定義動作で、 `unsafe` コード中であっても、避ける必要があります。
124115

125116
> 訳注:
@@ -183,15 +174,13 @@ avoided, even when writing `unsafe` code:
183174
In both unsafe functions and unsafe blocks, Rust will let you do three things
184175
that you normally can not do. Just three. Here they are:
185176
-->
186-
187177
アンセーフ関数・アンセーフブロックでは、Rustは普段できない3つのことをさせてくれます。たった3つです。それは、
188178

189179
<!--
190180
1. Access or update a [static mutable variable][static].
191181
2. Dereference a raw pointer.
192182
3. Call unsafe functions. This is the most powerful ability.
193183
-->
194-
195184
1. [静的ミュータブル変数][static]のアクセスとアップデート。
196185
2. 生ポインタの参照外し。
197186
3. アンセーフ関数の呼び出し。これが最も強力な能力です。
@@ -202,7 +191,6 @@ borrow checker’. Adding `unsafe` to some random Rust code doesn’t change its
202191
semantics, it won’t just start accepting anything. But it will let you write
203192
things that _do_ break some of the rules.
204193
-->
205-
206194
以上です。
207195
重要なのは、 `unsafe` が、たとえば「借用チェッカをオフにする」といったことを行わないことです。
208196
Rustのコードの適当な位置に `unsafe` を加えてもセマンティクスは変わらず、何でもただ受理するようになるということにはなりません。
@@ -213,14 +201,12 @@ You will also encounter the `unsafe` keyword when writing bindings to foreign
213201
(non-Rust) interfaces. You're encouraged to write a safe, native Rust interface
214202
around the methods provided by the library.
215203
-->
216-
217204
また、`unsafe` キーワードは、Rust以外の言語とのインターフェースを書くときに遭遇するでしょう。
218205
ライブラリの提供するメソッドの周りに、安全な、Rustネイティブのインターフェースを書くことが推奨されています。
219206

220207
<!--
221208
Let’s go over the basic three abilities listed, in order.
222209
-->
223-
224210
これから、その基本的な3つの能力を順番に見ていきましょう。
225211

226212
## `static mut` のアクセスとアップデート。
@@ -231,7 +217,6 @@ Rust has a feature called ‘`static mut`’ which allows for mutable global sta
231217
Doing so can cause a data race, and as such is inherently not safe. For more
232218
details, see the [static][static] section of the book.
233219
-->
234-
235220
Rustには「`static mut`」という、ミュータブルでグローバルな状態を実現する機能があります。
236221
これを使うことはデータレースが起こるおそれがあるので、本質的に安全ではありません。
237222
詳細は、この本の[static][static]セクションを参照してください。
@@ -247,7 +232,6 @@ different memory safety and security issues. In some senses, the ability to
247232
dereference an arbitrary pointer is one of the most dangerous things you can
248233
do. For more on raw pointers, see [their section of the book][rawpointers].
249234
-->
250-
251235
生ポインタによって任意のポインタ演算が可能になりますが、いくつもの異なるメモリ安全とセキュリティの問題が起こるおそれがあります。
252236
ある意味で、任意のポインタを参照外しする能力は行いうる操作のうち最も危険なもののひとつです。
253237
詳細は、[この本の生ポインタに関するセクション][rawpointers]を参照してください。
@@ -261,7 +245,6 @@ do. For more on raw pointers, see [their section of the book][rawpointers].
261245
This last ability works with both aspects of `unsafe`: you can only call
262246
functions marked `unsafe` from inside an unsafe block.
263247
-->
264-
265248
この最後の能力は、`unsafe`の両面とともに働きます。
266249
すなわち、`unsafe`で印付けられた関数は、アンセーフブロックの内部からのみ呼び出すことができます。
267250

@@ -270,7 +253,6 @@ This ability is powerful and varied. Rust exposes some [compiler
270253
intrinsics][intrinsics] as unsafe functions, and some unsafe functions bypass
271254
safety checks, trading safety for speed.
272255
-->
273-
274256
この能力は強力で多彩です。
275257
Rustはいくらかの[compiler intrinsics][intrinsics]をアンセーフ関数として公開しており、また、いくつかのアンセーフ関数は安全性検査を回避することで、安全性とスピードを引き換えています。
276258

@@ -279,7 +261,6 @@ I’ll repeat again: even though you _can_ do arbitrary things in unsafe blocks
279261
and functions doesn’t mean you should. The compiler will act as though you’re
280262
upholding its invariants, so be careful!
281263
-->
282-
283264
繰り返しになりますが、アンセーフブロックと関数の内部で任意のことが _できる_ としても、それをすべきだということを意味しません。コンパイラは、あなたが不変量を守っているかのように動作しますから、注意してください!
284265

285266
[intrinsics]: intrinsics.html

0 commit comments

Comments
 (0)