Skip to content

Commit 981e511

Browse files
committed
Merge branch 'master' into markdown-syntax-space
2 parents 3d57970 + 2f3f7a6 commit 981e511

26 files changed

+2883
-1353
lines changed

1.6/ja/book/attributes.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
% Attributes
1+
% アトリビュート
2+
<!-- % Attributes -->
23

3-
Declarations can be annotated with ‘attributes’ in Rust. They look like this:
4+
<!-- Declarations can be annotated with ‘attributes’ in Rust. They look like this: -->
5+
Rustでは以下のように「アトリビュート」によって宣言を修飾することができます。
46

57
```rust
68
#[test]
79
# fn foo() {}
810
```
911

10-
or like this:
12+
<!-- or like this: -->
13+
または以下のように:
1114

1215
```rust
1316
# mod foo {
1417
#![test]
1518
# }
1619
```
1720

18-
The difference between the two is the `!`, which changes what the attribute
19-
applies to:
21+
<!-- The difference between the two is the `!`, which changes what the attribute -->
22+
<!-- applies to: -->
23+
2つの違いは `!` に有ります、 `!` はアトリビュートが適用されるものを変更します:
2024

2125
```rust,ignore
2226
#[foo]
@@ -27,12 +31,18 @@ mod bar {
2731
}
2832
```
2933

30-
The `#[foo]` attribute applies to the next item, which is the `struct`
31-
declaration. The `#![bar]` attribute applies to the item enclosing it, which is
32-
the `mod` declaration. Otherwise, they’re the same. Both change the meaning of
33-
the item they’re attached to somehow.
34+
<!-- The `#[foo]` attribute applies to the next item, which is the `struct` -->
35+
<!-- declaration. The `#![bar]` attribute applies to the item enclosing it, which is -->
36+
<!-- the `mod` declaration. Otherwise, they’re the same. Both change the meaning of -->
37+
<!-- the item they’re attached to somehow. -->
38+
`#[foo]` アトリビュートは次のアイテムに適用され、この場合は `struct` 宣言に適用されます。
39+
`#![bar]` アトリビュートは `#![bar]` アトリビュートを囲んでいるアイテムに適用され、この場合は `mod` 宣言に適用されます。
40+
その他の点については同じであり、どちらも適用されたアイテムの意味を変化させます。
3441

35-
For example, consider a function like this:
42+
43+
44+
<!-- For example, consider a function like this: -->
45+
例を挙げると、たとえば以下の様な関数では:
3646

3747
```rust
3848
#[test]
@@ -41,30 +51,37 @@ fn check() {
4151
}
4252
```
4353

44-
It is marked with `#[test]`. This means it’s special: when you run
45-
[tests][tests], this function will execute. When you compile as usual, it won’t
46-
even be included. This function is now a test function.
54+
<!-- It is marked with `#[test]`. This means it’s special: when you run -->
55+
<!-- [tests][tests], this function will execute. When you compile as usual, it won’t -->
56+
<!-- even be included. This function is now a test function. -->
57+
この関数は `#[test]` によってマークされており、これは [テスト][tests] を走らせた時に実行されるという特別な意味になります。
58+
通常通りにコンパイルをした場合は、コンパイル結果に含まれません。この関数は今やテスト関数なのです。
4759

48-
[tests]: testing.html
60+
[テスト]: testing.html
4961

50-
Attributes may also have additional data:
62+
<!-- Attributes may also have additional data: -->
63+
アトリビュートは以下のように、追加のデータを持つことができます:
5164

5265
```rust
5366
#[inline(always)]
5467
fn super_fast_fn() {
5568
# }
5669
```
5770

58-
Or even keys and values:
71+
<!-- Or even keys and values: -->
72+
また、キーと値についても持つことができます:
5973

6074
```rust
6175
#[cfg(target_os = "macos")]
6276
mod macos_only {
6377
# }
6478
```
6579

66-
Rust attributes are used for a number of different things. There is a full list
67-
of attributes [in the reference][reference]. Currently, you are not allowed to
68-
create your own attributes, the Rust compiler defines them.
80+
<!-- Rust attributes are used for a number of different things. There is a full list -->
81+
<!-- of attributes [in the reference][reference]. Currently, you are not allowed to -->
82+
<!-- create your own attributes, the Rust compiler defines them. -->
83+
Rustのアトリビュートは様々なことに利用されます。
84+
すべてのアトリビュートのリストは [リファレンス][reference] に載っています。
85+
現在は、Rustコンパイラーによって定義されている以外の独自のアトリビュートを作成することは許可されていません。
6986

70-
[reference]: ../reference.html#attributes
87+
[リファレンス]: ../reference.html#attributes

1.6/ja/book/comments.md

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1-
% Comments
1+
% コメント
2+
<!-- % Comments -->
23

3-
Now that we have some functions, it’s a good idea to learn about comments.
4-
Comments are notes that you leave to other programmers to help explain things
5-
about your code. The compiler mostly ignores them.
4+
<!-- Now that we have some functions, it’s a good idea to learn about comments. -->
5+
<!-- Comments are notes that you leave to other programmers to help explain things -->
6+
<!-- about your code. The compiler mostly ignores them. -->
7+
いくつかの関数ができたので、コメントについて学ぶことはよい考えです。
8+
コメントはコードについての何かを説明する助けになるように、他のプログラマに残すメモです。
9+
コンパイラはそれらをほとんど無視します。
610

7-
Rust has two kinds of comments that you should care about: *line comments*
8-
and *doc comments*.
11+
<!-- Rust has two kinds of comments that you should care about: *line comments* -->
12+
<!-- and *doc comments*. -->
13+
Rustには気にすべき2種類のコメント、 *行コメント**ドキュメンテーションコメント* があります。
914

1015
```rust
11-
// Line comments are anything after ‘//’ and extend to the end of the line.
16+
# // Line comments are anything after ‘//’ and extend to the end of the line.
17+
// 行コメントは「//」以降の全ての文字であり、行末まで続く
1218

1319
let x = 5; // this is also a line comment.
1420

15-
// If you have a long explanation for something, you can put line comments next
16-
// to each other. Put a space between the // and your comment so that it’s
17-
// more readable.
21+
# // If you have a long explanation for something, you can put line comments next
22+
# // to each other. Put a space between the // and your comment so that it’s
23+
# // more readable.
24+
// もし何かのために長い説明を書くのであれば、行コメントを複数行に渡って書くこと
25+
// ができる。//とコメントとの間にスペースを置くことで、より読みやすくなる
1826
```
1927

20-
The other kind of comment is a doc comment. Doc comments use `///` instead of
21-
`//`, and support Markdown notation inside:
28+
<!-- The other kind of comment is a doc comment. Doc comments use `///` instead of -->
29+
<!-- `//`, and support Markdown notation inside: -->
30+
その他の種類のコメントはドキュメンテーションコメントです。
31+
ドキュメンテーションコメントは`//`の代わりに`///`を使い、その中でMarkdown記法をサポートします。
2232

2333
```rust
24-
/// Adds one to the number given.
34+
# /// Adds one to the number given.
35+
/// 与えられた数値に1を加える
2536
///
2637
/// # Examples
2738
///
@@ -38,22 +49,30 @@ fn add_one(x: i32) -> i32 {
3849
}
3950
```
4051

41-
There is another style of doc comment, `//!`, to comment containing items (e.g.
42-
crates, modules or functions), instead of the items following it. Commonly used
43-
inside crates root (lib.rs) or modules root (mod.rs):
52+
<!-- There is another style of doc comment, `//!`, to comment containing items (e.g. -->
53+
<!-- crates, modules or functions), instead of the items following it. Commonly used -->
54+
<!-- inside crates root (lib.rs) or modules root (mod.rs): -->
55+
もう1つのスタイルのドキュメンテーションコメントに`//!`があります。これは、その後に続く要素ではなく、それを含んでいる要素(例えばクレート、モジュール、関数)にコメントを付けます。
56+
一般的にはクレートルート(lib.rs)やモジュールルート(mod.rs)の中で使われます。
4457

4558
```
46-
//! # The Rust Standard Library
59+
//! # Rust標準ライブラリ
4760
//!
48-
//! The Rust Standard Library provides the essential runtime
49-
//! functionality for building portable Rust software.
61+
//! Rust標準ライブラリはポータブルなRustソフトウェアをビルドするために不可欠な
62+
//! ランタイム関数を提供する。
5063
```
5164

52-
When writing doc comments, providing some examples of usage is very, very
53-
helpful. You’ll notice we’ve used a new macro here: `assert_eq!`. This compares
54-
two values, and `panic!`s if they’re not equal to each other. It’s very helpful
55-
in documentation. There’s another macro, `assert!`, which `panic!`s if the
56-
value passed to it is `false`.
65+
<!-- When writing doc comments, providing some examples of usage is very, very -->
66+
<!-- helpful. You’ll notice we’ve used a new macro here: `assert_eq!`. This compares -->
67+
<!-- two values, and `panic!`s if they’re not equal to each other. It’s very helpful -->
68+
<!-- in documentation. There’s another macro, `assert!`, which `panic!`s if the -->
69+
<!-- value passed to it is `false`. -->
70+
ドキュメンテーションコメントを書いているとき、いくつかの使い方の例を提供することは非常に非常に有用です。
71+
ここでは新しいマクロ、`assert_eq!`を使っていることに気付くでしょう。
72+
これは2つの値を比較し、もしそれらが互いに等しくなければ`panic!`します。
73+
これはドキュメントの中で非常に便利です。
74+
もう1つのマクロ、`assert!`は、それに渡された値が`false`であれば`panic!`します。
5775

58-
You can use the [`rustdoc`](documentation.html) tool to generate HTML documentation
59-
from these doc comments, and also to run the code examples as tests!
76+
<!-- You can use the [`rustdoc`](documentation.html) tool to generate HTML documentation -->
77+
<!-- from these doc comments, and also to run the code examples as tests! -->
78+
それらのドキュメンテーションコメントからHTMLドキュメントを生成するため、そしてコード例をテストとして実行するためにも[`rustdoc`](documentation.html)ツールを使うことができます!

0 commit comments

Comments
 (0)