Skip to content

Commit 2e56cf5

Browse files
引用されたコードに citation を追加
1 parent 931112e commit 2e56cf5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/rust-2018/tyvar-behind-raw-pointer.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ See Rust issue [#46906] for details.
3636
詳細は Rust のイシュー [#46906] を参照してください。
3737

3838
> *訳注*:
39-
> 詳しく解説します。以下のプログラムをご覧ください。
39+
> 詳しく解説します。以下のプログラムをご覧ください[^citation-46906]
4040
>
4141
> ```rust,ignore
4242
> let s = libc::getenv(k.as_ptr()) as *const _;
@@ -55,7 +55,7 @@ See Rust issue [#46906] for details.
5555
> この新機能は "arbitrary self types" (self の型の任意化)と呼ばれます。
5656
> しかし、これが導入されると困ったことが起きます。
5757
>
58-
> 次のような構造体があったとしましょう:
58+
> 次のような構造体があったとしましょう[^citation-46906]:
5959
> ```rust,ignore
6060
> #![feature(arbitrary_self_types)]
6161
>
@@ -77,7 +77,7 @@ See Rust issue [#46906] for details.
7777
> もう一つは今 `*const MyType` に対して実装された `is_null` です。
7878
> つまり、メソッドの呼び出しに曖昧性が生じています。
7979
>
80-
> この問題の解決策は簡単です。キャスト後の型がどの定数ポインタになるのか明示すればよいです:
80+
> この問題の解決策は簡単です。キャスト後の型がどの定数ポインタになるのか明示すればよいです[^citation-46906]:
8181
>
8282
> ```rust,ignore
8383
> let s = libc::getenv(k.as_ptr()) as *const libc::c_char;
@@ -91,6 +91,8 @@ See Rust issue [#46906] for details.
9191
> こうした理由から、 `*const _` や `*mut _` など、「未知の型への生ポインタ」に対してメソッドを呼び出すと、コンパイラがそれを検知するようになりました。
9292
> 最初は警告リントとして導入されましたが、Rust 2018 エディションでハードエラーに格上げされました。これが、本ページで説明されている変更点です。
9393
94+
[^citation-46906]: これらのソースコードは [mikeyhew](https://github.com/mikeyhew) 氏による [rust-lang/rust#46906 へのコメント](https://github.com/rust-lang/rust/issues/46906#issue-283871408)より引用されたものです。ただし、コメントが著者によって追加されています。
95+
9496
[^2]: 関連関数のうち、第一引数が `self` であるものは、メソッド呼び出し演算子(`.`)を用いて呼び出すことができます。
9597
このような関連関数をメソッドと呼びます。
9698
`s.is_null()` と書くと、これは `s` に対してメソッド `is_null(...)` を呼び出していることになります。

0 commit comments

Comments
 (0)