Skip to content

Commit e2bc65c

Browse files
「新しいキーワード」を翻訳
1 parent e586015 commit e2bc65c

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

TranslationTable.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
| specialized | 特殊化された
199199
| standard library | 標準ライブラリ
200200
| statement | 文
201+
| strict keyword | 正格キーワード
201202
| string | 文字列
202203
| string interpolation | 文字列インターポーレーション
203204
| string slice | 文字列スライス

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
- [Rust 2018](rust-2018/index.md)
3535
- [Path and module system changes](rust-2018/path-changes.md)
3636
- [Anonymous trait function parameters deprecated](rust-2018/trait-fn-parameters.md)
37-
- [New keywords](rust-2018/new-keywords.md)
37+
- [新しいキーワード](rust-2018/new-keywords.md)
3838
- [Method dispatch for raw pointers to inference variables](rust-2018/tyvar-behind-raw-pointer.md)
3939
- [Cargo changes](rust-2018/cargo.md)
4040

src/rust-2018/new-keywords.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,154 @@
1+
<!--
12
# New keywords
3+
-->
24

5+
# 新しいキーワード
6+
7+
<!--
38
![Minimum Rust version: 1.27](https://img.shields.io/badge/Minimum%20Rust%20Version-1.27-brightgreen.svg)
9+
-->
10+
11+
![導入 Rust バージョン: 1.27](https://img.shields.io/badge/%E5%B0%8E%E5%85%A5%20Rust%20%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3-1.27-brightgreen.svg)
412

13+
<!--
514
## Summary
15+
-->
616

17+
## 概要
18+
19+
<!--
720
- `dyn` is a [strict keyword][strict], in 2015 it is a [weak keyword].
821
- `async` and `await` are [strict keywords][strict].
922
- `try` is a [reserved keyword].
23+
-->
24+
25+
- `dyn`[正格キーワード][strict]です。2015 では[弱いキーワード][strict]です。
26+
- `asnyc``await`[正格キーワード][strict]です。
27+
- `try`[予約キーワード]です。
1028

29+
<!--
1130
[strict]: https://doc.rust-lang.org/reference/keywords.html#strict-keywords
1231
[weak keyword]: https://doc.rust-lang.org/reference/keywords.html#weak-keywords
1332
[reserved keyword]: https://doc.rust-lang.org/reference/keywords.html#reserved-keywords
33+
-->
1434

35+
[strict]: https://doc.rust-lang.org/reference/keywords.html#strict-keywords
36+
[弱いキーワード]: https://doc.rust-lang.org/reference/keywords.html#weak-keywords
37+
[予約キーワード]: https://doc.rust-lang.org/reference/keywords.html#reserved-keywords
38+
39+
<!--
1540
## Motivation
41+
-->
42+
43+
## 動機
1644

45+
<!--
1746
### `dyn Trait` for trait objects
47+
-->
48+
49+
### トレイトオブジェクトを表す `dyn Trait`
1850

51+
<!--
1952
The `dyn Trait` feature is the new syntax for using trait objects. In short:
53+
-->
2054

55+
`dyn Trait` 機能は、トレイトオブジェクトを使うための新しい構文です。簡単に言うと:
56+
57+
<!--
2158
* `Box<Trait>` becomes `Box<dyn Trait>`
2259
* `&Trait` and `&mut Trait` become `&dyn Trait` and `&mut dyn Trait`
60+
-->
61+
62+
* `Box<Trait>``Box<dyn Trait>` になり、
63+
* `&Trait``&mut Trait``&dyn Trait``&mut dyn Trait` になる
2364

65+
<!--
2466
And so on. In code:
67+
-->
68+
69+
といった具合です。プログラム内では:
2570

2671
```rust
2772
trait Trait {}
2873

2974
impl Trait for i32 {}
3075

3176
// old
77+
// いままで
3278
fn function1() -> Box<Trait> {
3379
# unimplemented!()
3480
}
3581

3682
// new
83+
// これから
3784
fn function2() -> Box<dyn Trait> {
3885
# unimplemented!()
3986
}
4087
```
4188

89+
<!--
4290
That's it!
91+
-->
4392

93+
これだけです!
94+
95+
<!--
4496
#### Why?
97+
-->
98+
99+
#### なぜ?
45100

101+
<!--
46102
Using just the trait name for trait objects turned out to be a bad decision.
47103
The current syntax is often ambiguous and confusing, even to veterans,
48104
and favors a feature that is not more frequently used than its alternatives,
49105
is sometimes slower, and often cannot be used at all when its alternatives can.
106+
-->
50107

108+
トレイトオブジェクトにトレイト名をそのまま使うのは悪手だったと、後になって分かりました。
109+
今までの構文は、経験者にとってさえ往々にして曖昧にして難解で、代替のものより頻繁に使われない機能が優遇され<!-- TODO: "a feature that is not more frequently used" とは何のことですか?-->、時には遅く、代替機能にはできることができないのです。
110+
111+
<!--
51112
Furthermore, with `impl Trait` arriving, "`impl Trait` vs `dyn Trait`" is much
52113
more symmetric, and therefore a bit nicer, than "`impl Trait` vs `Trait`".
53114
`impl Trait` is explained [here][impl-trait].
115+
-->
116+
117+
その上、`impl Trait` が入ったことで、「`impl Trait``dyn Trait` か」の関係はより対称的になり、「`impl Trait``Trait` か」よりちょっといい感じです。
118+
`impl Trait` の説明は[こちら][impl-trait]です。
54119

120+
<!--
55121
In the new edition, you should therefore prefer `dyn Trait` to just `Trait`
56122
where you need a trait object.
123+
-->
124+
125+
したがって、新しいエディションでは、トレイトオブジェクトが必要なときは、ただの `Trait` でなく `dyn Trait` を使うべきです。
57126

58127
<!--
59128
[impl-trait]: ../../rust-by-example/trait/impl_trait.html
60129
-->
61130
[impl-trait]: https://doc.rust-jp.rs/rust-by-example-ja/rust-by-example/trait/impl_trait.html
62131

132+
<!--
63133
### `async` and `await`
134+
-->
64135

136+
### `async``await`
137+
138+
<!--
65139
These keywords are reserved to implement the async-await feature of Rust, which was ultimately [released to stable in 1.39.0](https://blog.rust-lang.org/2019/11/07/Async-await-stable.html).
140+
-->
66141

142+
これらのキーワードは Rust に非同期の機能を実装するために予約されました。非同期の機能は[最終的に 1.39.0 でリリースされました](https://blog.rust-lang.org/2019/11/07/Async-await-stable.html)
143+
144+
<!--
67145
### `try` keyword
146+
-->
147+
148+
### キーワード `try`
68149

150+
<!--
69151
The `try` keyword is reserved for use in `try` blocks, which have not (as of this writing) been stabilized ([tracking issue](https://github.com/rust-lang/rust/issues/31436))
152+
-->
153+
154+
キーワード `try``try` ブロックで使うために予約されましたが、(これを書いている時点で)まだ安定化されていません([追跡イシュー](https://github.com/rust-lang/rust/issues/31436)

0 commit comments

Comments
 (0)