Skip to content

Fix typo and improve Japanese #214

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 4 commits into from
Nov 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1.6/ja/book/choosing-your-guarantees.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ let x = RefCell::new(vec![1,2,3,4]);
C++の `shared_ptr` は `Arc` と似ていますが、C++の場合、中身のデータは常にミュータブルです。
C++と同じセマンティクスで使うためには、 `Arc<Mutex<T>>` 、 `Arc<RwLock<T>>` 、 `Arc<UnsafeCell<T>>` を使うべきです [^4] ( `UnsafeCell<T>` はどんなデータでも持つことができ、実行時のコストも掛かりませんが、それにアクセスするためには `unsafe` ブロックが必要というセル型です)。
最後のものは、その使用がメモリをアンセーフにしないことを確信している場合にだけ使うべきです。
次のことを覚えましょう。構造体に書き込むのはアトミックな作業ではなく、`vec.push()`のような多くの関数は内部でメモリの再割当てを行い、アンセーフな挙動を引き起こす可能性があります。そのため単純な操作であるということだけでは `UnsafeCall` を正当化するには十分ではありません。
次のことを覚えましょう。構造体に書き込むのはアトミックな作業ではなく、`vec.push()`のような多くの関数は内部でメモリの再割当てを行い、アンセーフな挙動を引き起こす可能性があります。そのため単純な操作であるということだけでは `UnsafeCell` を正当化するには十分ではありません。

<!--[^4]: `Arc<UnsafeCell<T>>` actually won't compile since `UnsafeCell<T>` isn't `Send` or `Sync`, but we can wrap it in a type and implement `Send`/`Sync` for it manually to get `Arc<Wrapper<T>>` where `Wrapper` is `struct Wrapper<T>(UnsafeCell<T>)`.-->
[^4]: `Arc<UnsafeCell<T>>` は `Send` や `Sync` ではないため、実際にはコンパイルできません。しかし、 `Arc<Wrapper<T>>` を得るために、手動でそれを `Send` と `Sync` を実装した型でラップすることができます。ここでの `Wrapper` は `struct Wrapper<T>(UnsafeCell<T>)` です。
Expand Down
14 changes: 7 additions & 7 deletions 1.6/ja/book/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Rustでは戻り値を使います。
# // Guess a number between 1 and 10.
# // If it matches the number we had in mind, return true. Else, return false.
// 1から10までの数字を予想します。
// もし予想した数字に一致したらtrueを返し、そうでなけれは、falseを返します
// もし予想した数字に一致したらtrueを返し、そうでなければfalseを返します
fn guess(n: i32) -> bool {
if n < 1 || n > 10 {
panic!("Invalid number: {}", n);
Expand Down Expand Up @@ -314,7 +314,7 @@ impl<T> Option<T> {
> 訳注:
>
> called `Option::unwrap()` on a `None` value:<br/>
> `None` な値に対して `Option:unwpal()` が呼ばれました
> `None` な値に対して `Option:unwrap()` が呼ばれました

<!-- The `unwrap` method *abstracts away the case analysis*. This is precisely the thing -->
<!-- that makes `unwrap` ergonomic to use. Unfortunately, that `panic!` means that -->
Expand Down Expand Up @@ -1178,7 +1178,7 @@ fn main() {
<!-- `map_err`. -->
このコードは、やや難解になってきました。
このようなコードを簡単に書けるようになるまでには、結構な量の練習が必要かもしれません。
こういうもの書くときは *型に導かれる* ようにします。
こういうものを書くときは *型に導かれる* ようにします。
`file_double` のリターン型を `Result<i32, String>` に変更したらすぐに、それに合ったコンビネータを探し始めるのです。
この例では `and_then`, `map`, `map_err` の、3種類のコンビネータだけを使いました。

Expand All @@ -1188,7 +1188,7 @@ fn main() {
<!-- Correspondingly, there are two calls to `and_then`. -->
`and_then` は、エラーを返すかもしれない処理同士を繋いでいくために使います。
ファイルを開いた後に、失敗するかもしれない処理が2つあります:
ファイルからの読み込む所と、内容を数値としてパースする所です。
ファイルから読み込む所と、内容を数値としてパースする所です。
これに対応して `and_then` も2回呼ばれています。

<!-- `map` is used to apply a function to the `Ok(...)` value of a `Result`. For -->
Expand Down Expand Up @@ -1855,7 +1855,7 @@ fn file_double<P: AsRef<Path>>(file_path: P) -> Result<i32, Box<Error>> {
<!-- automatic type conversion for us by calling `From::from` on the error value. -->
<!-- In particular, we converted errors to `Box<Error>`, which works, but the type -->
<!-- is opaque to callers. -->
最後の節では `try!` マクロの本当の定義を確認し、それが `From::from` をエラーの値に対して呼ぶことで、自動的な型変換をする様子を見ました。
前の節では `try!` マクロの本当の定義を確認し、それが `From::from` をエラーの値に対して呼ぶことで、自動的な型変換をする様子を見ました。
特にそこでは、エラーを `Box<Error>` に変換しました。
これはたしかに動きますが、呼び出し元にとって、型がオペークになってしまいました。

Expand Down Expand Up @@ -2162,11 +2162,11 @@ fn main() {

let matches = match opts.parse(&args[1..]) {
Ok(m) => { m }
Err(e) => { panic!(e.to_string()) }
Err(e) => { panic!(e.to_string()) }
};
if matches.opt_present("h") {
print_usage(&program, opts);
return;
return;
}
let data_path = args[1].clone();
let city = args[2].clone();
Expand Down
1 change: 0 additions & 1 deletion 1.6/ja/book/ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ int32_t register_callback(void* callback_target, rust_callback callback) {
}

void trigger_callback() {
# // cb(cb_target, 7); // Will call callback(&rustObject, 7) in Rust
cb(cb_target, 7); // Rustのcallback(&rustObject, 7)を呼び出す
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cシンタックスのためか、非表示とならずドキュメントにそのまま表示されていたので削除しました。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1つ上のコードブロックでは消してるのにこちらは処理し忘れてますね。細かいところまでありがとうございます。

}
```
Expand Down
2 changes: 1 addition & 1 deletion 1.9/ja/book/choosing-your-guarantees.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ let x = RefCell::new(vec![1,2,3,4]);
C++の `shared_ptr` は `Arc` と似ていますが、C++の場合、中身のデータは常にミュータブルです。
C++と同じセマンティクスで使うためには、 `Arc<Mutex<T>>` 、 `Arc<RwLock<T>>` 、 `Arc<UnsafeCell<T>>` を使うべきです [^4] ( `UnsafeCell<T>` はどんなデータでも持つことができ、実行時のコストも掛かりませんが、それにアクセスするためには `unsafe` ブロックが必要というセル型です)。
最後のものは、その使用がメモリをアンセーフにしないことを確信している場合にだけ使うべきです。
次のことを覚えましょう。構造体に書き込むのはアトミックな作業ではなく、`vec.push()`のような多くの関数は内部でメモリの再割当てを行い、アンセーフな挙動を引き起こす可能性があります。そのため単純な操作であるということだけでは `UnsafeCall` を正当化するには十分ではありません。
次のことを覚えましょう。構造体に書き込むのはアトミックな作業ではなく、`vec.push()`のような多くの関数は内部でメモリの再割当てを行い、アンセーフな挙動を引き起こす可能性があります。そのため単純な操作であるということだけでは `UnsafeCell` を正当化するには十分ではありません。

<!--[^4]: `Arc<UnsafeCell<T>>` actually won't compile since `UnsafeCell<T>` isn't `Send` or `Sync`, but we can wrap it in a type and implement `Send`/`Sync` for it manually to get `Arc<Wrapper<T>>` where `Wrapper` is `struct Wrapper<T>(UnsafeCell<T>)`.-->
[^4]: `Arc<UnsafeCell<T>>` は `Send` や `Sync` ではないため、実際にはコンパイルできません。しかし、 `Arc<Wrapper<T>>` を得るために、手動でそれを `Send` と `Sync` を実装した型でラップすることができます。ここでの `Wrapper` は `struct Wrapper<T>(UnsafeCell<T>)` です。
Expand Down
14 changes: 7 additions & 7 deletions 1.9/ja/book/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Rustでは戻り値を使います。
# // Guess a number between 1 and 10.
# // If it matches the number we had in mind, return true. Else, return false.
// 1から10までの数字を予想します。
// もし予想した数字に一致したらtrueを返し、そうでなけれは、falseを返します
// もし予想した数字に一致したらtrueを返し、そうでなければfalseを返します
fn guess(n: i32) -> bool {
if n < 1 || n > 10 {
panic!("Invalid number: {}", n);
Expand Down Expand Up @@ -314,7 +314,7 @@ impl<T> Option<T> {
> 訳注:
>
> called `Option::unwrap()` on a `None` value:<br/>
> `None` な値に対して `Option:unwpal()` が呼ばれました
> `None` な値に対して `Option:unwrap()` が呼ばれました

<!-- The `unwrap` method *abstracts away the case analysis*. This is precisely the thing -->
<!-- that makes `unwrap` ergonomic to use. Unfortunately, that `panic!` means that -->
Expand Down Expand Up @@ -1178,7 +1178,7 @@ fn main() {
<!-- `map_err`. -->
このコードは、やや難解になってきました。
このようなコードを簡単に書けるようになるまでには、結構な量の練習が必要かもしれません。
こういうもの書くときは *型に導かれる* ようにします。
こういうものを書くときは *型に導かれる* ようにします。
`file_double` のリターン型を `Result<i32, String>` に変更したらすぐに、それに合ったコンビネータを探し始めるのです。
この例では `and_then`, `map`, `map_err` の、3種類のコンビネータだけを使いました。

Expand All @@ -1188,7 +1188,7 @@ fn main() {
<!-- Correspondingly, there are two calls to `and_then`. -->
`and_then` は、エラーを返すかもしれない処理同士を繋いでいくために使います。
ファイルを開いた後に、失敗するかもしれない処理が2つあります:
ファイルからの読み込む所と、内容を数値としてパースする所です。
ファイルから読み込む所と、内容を数値としてパースする所です。
これに対応して `and_then` も2回呼ばれています。

<!-- `map` is used to apply a function to the `Ok(...)` value of a `Result`. For -->
Expand Down Expand Up @@ -1855,7 +1855,7 @@ fn file_double<P: AsRef<Path>>(file_path: P) -> Result<i32, Box<Error>> {
<!-- automatic type conversion for us by calling `From::from` on the error value. -->
<!-- In particular, we converted errors to `Box<Error>`, which works, but the type -->
<!-- is opaque to callers. -->
最後の節では `try!` マクロの本当の定義を確認し、それが `From::from` をエラーの値に対して呼ぶことで、自動的な型変換をする様子を見ました。
前の節では `try!` マクロの本当の定義を確認し、それが `From::from` をエラーの値に対して呼ぶことで、自動的な型変換をする様子を見ました。
特にそこでは、エラーを `Box<Error>` に変換しました。
これはたしかに動きますが、呼び出し元にとって、型がオペークになってしまいました。

Expand Down Expand Up @@ -2162,11 +2162,11 @@ fn main() {

let matches = match opts.parse(&args[1..]) {
Ok(m) => { m }
Err(e) => { panic!(e.to_string()) }
Err(e) => { panic!(e.to_string()) }
};
if matches.opt_present("h") {
print_usage(&program, opts);
return;
return;
}
let data_path = args[1].clone();
let city = args[2].clone();
Expand Down
1 change: 0 additions & 1 deletion 1.9/ja/book/ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ int32_t register_callback(void* callback_target, rust_callback callback) {
}

void trigger_callback() {
# // cb(cb_target, 7); // Will call callback(&rustObject, 7) in Rust
cb(cb_target, 7); // Rustのcallback(&rustObject, 7)を呼び出す
}
```
Expand Down