@@ -1438,7 +1438,7 @@ <h2 id="詳細"><a class="header" href="#詳細">詳細</a></h2>
14381438In accordance with RFC [#1685](https://github.com/rust-lang/rfcs/pull/1685),
14391439parameters in trait method declarations are no longer allowed to be anonymous.
14401440-->
1441- < p > RFC < a href ="https://github.com/rust-lang/rfcs/pull/1685 "> #1685</ a > に基づいて、トレイト関数のパラメータを匿名にすることはできなくなりました。</ p >
1441+ < p > RFC < a href ="https://github.com/rust-lang/rfcs/pull/1685 "> #1685</ a > に基づいて、トレイト関数のパラメータを匿名にすることはできなくなりました。</ p >
14421442<!--
14431443For example, in the 2015 edition, this was allowed:
14441444-->
@@ -1455,7 +1455,7 @@ <h2 id="詳細"><a class="header" href="#詳細">詳細</a></h2>
14551455In the 2018 edition, all parameters must be given an argument name (even if it's just
14561456`_`):
14571457-->
1458- < p > 2018 エディションでは、すべての引数名に (ただの < code > _</ code > であってもいいので、何らかの)名前がついていなければなりません:</ p >
1458+ < p > 2018 エディションでは、すべての引数に (ただの < code > _</ code > であってもいいので、何らかの)名前がついていなければなりません:</ p >
14591459< pre > < pre class ="playground "> < code class ="language-rust ">
14601460< span class ="boring "> #![allow(unused)]
14611461</ span > < span class ="boring "> fn main() {
@@ -1625,7 +1625,7 @@ <h2 id="詳細-1"><a class="header" href="#詳細-1">詳細</a></h2>
16251625< p > 詳細は Rust のイシュー < a href ="https://github.com/rust-lang/rust/issues/46906 "> #46906</ a > を参照してください。</ p >
16261626< blockquote >
16271627< p > < em > 訳注</ em > :
1628- 詳しく解説します。以下のプログラムをご覧ください。</ p >
1628+ 詳しく解説します。以下のプログラムをご覧ください< sup class =" footnote-reference " > < a href =" #citation-46906 " > 2 </ a > </ sup > 。</ p >
16291629< pre > < code class ="language-rust ignore "> let s = libc::getenv(k.as_ptr()) as *const _;
16301630s.is_null()
16311631</ code > </ pre >
@@ -1634,11 +1634,11 @@ <h2 id="詳細-1"><a class="header" href="#詳細-1">詳細</a></h2>
16341634< p > 2行目では、< code > *const _</ code > である < code > s</ code > に対して < code > .is_null()</ code > を呼び出しています。
16351635任意の型 < code > T</ code > について、プリミティブ型 < code > *const T</ code > は < a href ="https://doc.rust-lang.org/std/primitive.pointer.html#method.is_null-1 "> < code > is_null</ code > </ a > という固有メソッドを持つので、ここで呼び出されるのはこの固有メソッドです。</ p >
16361636< p > 問題はこの後です。
1637- 現在はメソッド< sup class ="footnote-reference "> < a href ="#2 "> 2 </ a > </ sup > を呼べる型は< a href ="https://doc.rust-lang.org/reference/items/associated-items.html#methods "> 一部の型に限られて</ a > いますが、
1637+ 現在はメソッド< sup class ="footnote-reference "> < a href ="#2 "> 3 </ a > </ sup > を呼べる型は< a href ="https://doc.rust-lang.org/reference/items/associated-items.html#methods "> 一部の型に限られて</ a > いますが、
16381638将来それを任意の型に拡張しようという< a href ="https://github.com/rust-lang/rust/issues/44874 "> 提案</ a > が出ています。
16391639この新機能は "arbitrary self types" (self の型の任意化)と呼ばれます。
16401640しかし、これが導入されると困ったことが起きます。</ p >
1641- < p > 次のような構造体があったとしましょう:</ p >
1641+ < p > 次のような構造体があったとしましょう< sup class =" footnote-reference " > < a href =" #citation-46906 " > 2 </ a > </ sup > :</ p >
16421642< pre > < code class ="language-rust ignore "> #![feature(arbitrary_self_types)]
16431643
16441644struct MyType;
@@ -1657,7 +1657,7 @@ <h2 id="詳細-1"><a class="header" href="#詳細-1">詳細</a></h2>
165716571つは先程の < code > *const T</ code > に対して実装された < a href ="https://doc.rust-lang.org/std/primitive.pointer.html#method.is_null-1 "> < code > is_null</ code > </ a > 、
16581658もう一つは今 < code > *const MyType</ code > に対して実装された < code > is_null</ code > です。
16591659つまり、メソッドの呼び出しに曖昧性が生じています。</ p >
1660- < p > この問題の解決策は簡単です。キャスト後の型がどの定数ポインタになるのか明示すればよいです:</ p >
1660+ < p > この問題の解決策は簡単です。キャスト後の型がどの定数ポインタになるのか明示すればよいです< sup class =" footnote-reference " > < a href =" #citation-46906 " > 2 </ a > </ sup > :</ p >
16611661< pre > < code class ="language-rust ignore "> let s = libc::getenv(k.as_ptr()) as *const libc::c_char;
16621662s.is_null()
16631663</ code > </ pre >
@@ -1667,7 +1667,10 @@ <h2 id="詳細-1"><a class="header" href="#詳細-1">詳細</a></h2>
16671667< p > こうした理由から、 < code > *const _</ code > や < code > *mut _</ code > など、「未知の型への生ポインタ」に対してメソッドを呼び出すと、コンパイラがそれを検知するようになりました。
16681668最初は警告リントとして導入されましたが、Rust 2018 エディションでハードエラーに格上げされました。これが、本ページで説明されている変更点です。</ p >
16691669</ blockquote >
1670- < div class ="footnote-definition " id ="2 "> < sup class ="footnote-definition-label "> 2</ sup >
1670+ < div class ="footnote-definition " id ="citation-46906 "> < sup class ="footnote-definition-label "> 2</ sup >
1671+ < p > これらのソースコードは < a href ="https://github.com/mikeyhew "> mikeyhew</ a > 氏による < a href ="https://github.com/rust-lang/rust/issues/46906#issue-283871408 "> rust-lang/rust#46906 へのコメント</ a > より引用されたものです。ただし、コメントが著者によって追加されています。</ p >
1672+ </ div >
1673+ < div class ="footnote-definition " id ="2 "> < sup class ="footnote-definition-label "> 3</ sup >
16711674< p > 関連関数のうち、第一引数が < code > self</ code > であるものは、メソッド呼び出し演算子(< code > .</ code > )を用いて呼び出すことができます。
16721675このような関連関数をメソッドと呼びます。
16731676< code > s.is_null()</ code > と書くと、これは < code > s</ code > に対してメソッド < code > is_null(...)</ code > を呼び出していることになります。
@@ -1860,6 +1863,7 @@ <h4 id="dyn-trait-オブジェクトの固有メソッド"><a class="header" hre
18601863</ span > mod submodule {
18611864 pub trait MyTrait {
18621865 // This has the same name as `TryInto::try_into`
1866+ // これは `TryInto::try_into` と同名
18631867 fn try_into(&self) -> Result<u32, ()>;
18641868 }
18651869}
@@ -2167,7 +2171,7 @@ <h3 id="ビルドの失敗"><a class="header" href="#ビルドの失敗">ビル
21672171-->
21682172< p > これにより、 Cargo はホスト依存関係(proc-macro と build-dependencies)のフィーチャとして "postgres" を追加します。</ p >
21692173< blockquote >
2170- < p > 訳注:ホスト依存関係とは、コンパイラホスト(コンパイラを実行しているプラットフォーム)向けにビルド・実行される依存を指し、proc-macroクレートやbuild-dependencies配下の依存クレートが該当します 。
2174+ < p > 訳注:ホスト依存関係とは、コンパイラホスト(コンパイラを実行しているプラットフォーム)向けにビルド・実行される依存を指し、proc-macro クレートや build-dependencies 配下の依存クレートが該当します 。
21712175一方、通常の依存関係はコンパイルターゲットのプラットフォーム向けにビルドされます。</ p >
21722176</ blockquote >
21732177< p > これで、 < code > diesel_migrations</ code > の手続き的マクロは "postgres" フィーチャが有効化された状態で走り、正しくビルドされます。</ p >
@@ -2392,7 +2396,7 @@ <h2 id="移行-2"><a class="header" href="#移行-2">移行</a></h2>
23922396< pre > < pre class ="playground "> < code class ="language-rust "> fn main() {
23932397 let array = [1u8, 2, 3];
23942398 for x in array.iter() { // <- This line changed
2395- // <- この行を書き換えた
2399+ // この行を書き換えた
23962400 // x is a `&u8` in all editions
23972401 // x はすべてのエディションで `&u8`
23982402 }
0 commit comments