File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,13 @@ fn main() {
49
49
}
50
50
```
51
51
52
+ <!--
53
+ ### Calling Unsafe Functions
54
+ Some functions can be declared as `unsafe`, meaning it is the programmer's
55
+ responsibility to ensure correctness instead of the compiler's. One example
56
+ of this is [`std::slice::from_raw_parts`] which will create a slice given a
57
+ pointer to the first element and a length.
58
+ -->
52
59
### 安全でない関数呼び出し
53
60
いくつかの関数は ` unsafe ` として宣言できます。これはコンパイラの代わりにプログラマの責任で正しさを保証することを意味します。
54
61
例として [ ` std::slice::from_raw_parts ` ] があります。この関数は最初の要素へのポインタと長さを指定してスライスを作成します。
@@ -70,6 +77,12 @@ fn main() {
70
77
}
71
78
```
72
79
80
+ <!--
81
+ For `slice::from_raw_parts`, one of the assumptions which *must* be upheld is
82
+ that the pointer passed in points to valid memory and that the memory pointed to
83
+ is of the correct type. If these invariants aren't upheld then the program's
84
+ behaviour is undefined and there is no knowing what will happen.
85
+ -->
73
86
` slice::from_raw_parts ` は、以下の仮定に基づいて処理します。
74
87
- 渡されたポインタが有効なメモリ位置を指していること
75
88
- そのメモリに格納された値が正しい型であること
You can’t perform that action at this time.
0 commit comments