-
Notifications
You must be signed in to change notification settings - Fork 72
4.11. structs #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Correct items KeenS pointed out
- Loading branch information
commit a0af56469e228412e400fb39821789a17f6d9d6d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,7 @@ fn main() { | |
|
|
||
| <!-- Rust does not support field mutability at the language level, so you cannot | ||
| write something like this: --> | ||
| Rustは言語レベルでフィールドのミュータブル化に対応していないため、以下の様に書くことはできません。 | ||
| Rustは言語レベルでフィールドのミュータビリティに対応していないため、以下の様に書くことはできません。 | ||
|
|
||
|
|
||
| ```rust,ignore | ||
|
|
@@ -78,7 +78,7 @@ struct Point { | |
| used to field-level mutability, this may seem strange at first, but it | ||
| significantly simplifies things. It even lets you make things mutable for a short | ||
| time only: --> | ||
| ミュータブルは束縛に付与できる属性であり、構造体自体に付与できる属性ではありません。もしあなたがフィールドレベルのミュータブルを使うのであれば、初めこそ奇妙に見えるものの、非常に簡単に実現できる方法があります。以下の方法で少しの間だけミュータブルな構造体を作ることができます。 | ||
| ミュータビリティは束縛に付与できる属性であり、構造体自体に付与できる属性ではありません。もしあなたがフィールドレベルのミュータビリティを使うのであれば、初めこそ奇妙に見えるものの、非常に簡単に実現できる方法があります。以下の方法で少しの間だけミュータブルな構造体を作ることができます。 | ||
| <!-- ```rust,ignore | ||
| struct Point { | ||
| x: i32, | ||
|
|
@@ -151,7 +151,7 @@ let point = Point3d { z: 1, x: 2, .. origin }; | |
| <!-- Rust has another data type that’s like a hybrid between a [tuple][tuple] and a | ||
| `struct`, called a ‘tuple struct’. Tuple structs have a name, but | ||
| their fields don’t:--> | ||
| Rustには'タプル構造体'と呼ばれる、[タプル][tuple]と`struct`のハイブリットのようなデータ型があります。タプル構造体自体には名前がありますが、そのフィールドには名前がありません。 | ||
| Rustには「タプル構造体」と呼ばれる、[タプル][tuple]と`struct`のハイブリットのようなデータ型があります。タプル構造体自体には名前がありますが、そのフィールドには名前がありません。 | ||
|
|
||
| ```rust | ||
| struct Color(i32, i32, i32); | ||
|
|
@@ -190,7 +190,7 @@ struct Point { | |
|
|
||
| <!-- Now, we have actual names, rather than positions. Good names are important, | ||
| and with a `struct`, we have actual names. --> | ||
| 今、私たちはフィールドの位置ではなくフィールドの名前そのものを持っています。良い名前は重要で、`struct`を使うということは、名前そのものを持っているということです。 | ||
| 今、私たちはフィールドの位置ではなく実際のフィールドの名前を持っています。良い名前は重要で、`struct`を使うということは、実際に名前を持っているということです。 | ||
|
|
||
| > 訳注: 原文を元に噛み砕くと、「タプルはフィールドの並びによって区別され、構造体はフィールドの名前によって区別されます。これはタプルと構造体の最たる違いであり、構造体を持つことは名前を付けられたデータの集まりを持つことに等しいため、構造体における名前付けは重要です。」といった所でしょうか。 | ||
|
|
||
|
|
@@ -199,6 +199,7 @@ tuple struct with only one element. We call this the ‘newtype’ pattern, beca | |
| it allows you to create a new type, distinct from that of its contained value | ||
| and expressing its own semantic meaning: --> | ||
| タプル構造体が非常に便利な場合も_あります_が、1要素で使う場合だけです。タプル構造体の中に入っている値と、それ自体のセマンティックな表現を明確に区別できるような新しい型を作成できることから、私たちはこれを'newtype'パターンと呼んでいます。 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 英語の場合も鍵括弧を用いた方が良いでしょうか?(ここでは'newtype')
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 地の文が日本語なので鉤括弧でおねがいします。 |
||
|
|
||
| ```rust | ||
| struct Inches(i32); | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
英語の場合(ここでは'newtype')も鍵括弧にすべきでしょうか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
地の文が日本語なので鉤括弧でおねがいします。