Skip to content

[WIP] 5.10. Borrow and AsRef #77

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

Closed
wants to merge 123 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
5f00b79
start converting
KeenS Jan 29, 2016
9434788
Merge branch 'master' into markdown-syntax-space
KeenS Jan 31, 2016
3d57970
converted
KeenS Jan 31, 2016
981e511
Merge branch 'master' into markdown-syntax-space
KeenS Feb 1, 2016
c3d20f2
organize comments in code block
KeenS Feb 2, 2016
cc5199e
start translating
Nnwww Feb 5, 2016
f839e51
start to translate loop.md
yohhoy Feb 5, 2016
7fc2178
finish a provisionally translation
Nnwww Feb 6, 2016
cc940e1
correct mistakes
Nnwww Feb 7, 2016
d7a3404
translate loop.md
yohhoy Feb 7, 2016
40cfb89
Add more spaces
ykomatsu Feb 7, 2016
bfe7bf6
Add more spaces
ykomatsu Feb 7, 2016
6ca764b
fix translation
yohhoy Feb 8, 2016
e2330a9
fix some points
Nnwww Feb 8, 2016
e893b01
translate nightly-rust
dalance Feb 1, 2016
82a83e3
update translation
dalance Feb 3, 2016
cf81446
update translation
dalance Feb 3, 2016
0bebff7
update translation
dalance Feb 3, 2016
4e87374
update TranslationTable
dalance Feb 9, 2016
4ef7367
translate borrow-and-asref
dalance Feb 9, 2016
6a6ce8f
revert translation(ja->en) in string literal
yohhoy Feb 10, 2016
acc273f
Merge pull request #71 from yohhoy/loop
KeenS Feb 10, 2016
7e2d575
generate
KeenS Feb 10, 2016
7c1802f
Begin translation of ffi
ykomatsu Feb 10, 2016
11733ca
Start translation
pocket7878 Feb 10, 2016
702aa1a
Update ffi
ykomatsu Feb 10, 2016
19a1803
Update TranslationTable
ykomatsu Feb 10, 2016
d8e5276
fix translation
dalance Feb 11, 2016
b9f2b9e
Merge pull request #52 from dalance/nightly-rust
tatsuya6502 Feb 11, 2016
8e0d8f2
generate
tatsuya6502 Feb 11, 2016
be3f4fd
Roughly Translated.
pocket7878 Feb 11, 2016
c520dda
Fix translation.
pocket7878 Feb 11, 2016
06f088d
Start translation.
pocket7878 Feb 11, 2016
4f4ad2d
Start translation of enums.md
keiichiw Feb 11, 2016
f937155
Roughly Translated.
pocket7878 Feb 11, 2016
16d6072
Fix translation.
pocket7878 Feb 11, 2016
a00c43a
Fix translation
pocket7878 Feb 11, 2016
66abde8
Little fix translation
pocket7878 Feb 11, 2016
2b5991a
事 -> こと
pocket7878 Feb 11, 2016
7ec8e51
Translate enums.md
keiichiw Feb 11, 2016
3ae9205
Update ffi
ykomatsu Feb 11, 2016
6a95622
Merge branch 'master' into ffi
ykomatsu Feb 11, 2016
af5e588
translate comment
pocket7878 Feb 12, 2016
5b9d23f
"タグ付きユニオン" -> "タグ付き共用体"
keiichiw Feb 12, 2016
8da35e4
start translation
pocket7878 Feb 12, 2016
d819c13
Merge pull request #78 from ykomatsu/ffi
KeenS Feb 13, 2016
04d1f66
Merge pull request #79 from pocket7878/match
KeenS Feb 13, 2016
f590a12
Merge pull request #80 from pocket7878/operator-overload
KeenS Feb 13, 2016
3f76e29
Merge pull request #81 from kw-udon/4_12_enums
KeenS Feb 13, 2016
1c62395
Merge pull request #73 from ykomatsu/spaces
KeenS Feb 13, 2016
61102ad
Merge pull request #75 from Nnwww/3_2_Dining_Philosophers_fix
KeenS Feb 13, 2016
f7c78ff
generate
KeenS Feb 13, 2016
30025bd
Merge branch 'master' into markdown-syntax-space
KeenS Feb 13, 2016
cd39bb2
restore 「の」
KeenS Feb 13, 2016
cc2c0ad
Start translation of casting-between-types.md
keiichiw Feb 12, 2016
1aeb62a
Translate casting-between-types.md
keiichiw Feb 13, 2016
6645b64
translate release-channels
dalance Feb 9, 2016
564686a
update translation
dalance Feb 12, 2016
c78544b
update TranslationTable
dalance Feb 12, 2016
f9d080c
update translation
dalance Feb 13, 2016
469dc87
Merge pull request #76 from dalance/release-channels
KeenS Feb 13, 2016
7c4381e
[WIP] 4.36 Unsafe
mandel59 Feb 13, 2016
9e96d23
reflect reviews
Nnwww Feb 13, 2016
3bfd150
Start translation of concurrency.md
keiichiw Feb 13, 2016
c3aa9c9
Reflect comments
keiichiw Feb 13, 2016
a120a1c
Translate 'scoped' as 「スコープ化された」
keiichiw Feb 13, 2016
f2d6a1f
Unsafeの翻訳
mandel59 Feb 13, 2016
3313c4d
対訳表の追加
mandel59 Feb 13, 2016
e0690b1
訳注の修正
mandel59 Feb 13, 2016
df32124
Merge pull request #85 from kw-udon/4_29_casting_between_types
KeenS Feb 14, 2016
5e06df8
generate
KeenS Feb 14, 2016
8e7707c
fix markdown syntax
Nnwww Feb 14, 2016
a719264
Merge pull request #58 from KeenS/block-code-comment
tatsuya6502 Feb 14, 2016
65775b8
generate
tatsuya6502 Feb 14, 2016
90ea4ff
Merge pull request #68 from Nnwww/4_35_Raw_Pointers
KeenS Feb 14, 2016
88753c7
規約に則した空行の削除
mandel59 Feb 14, 2016
4a77252
用語の変更: アンワインディング→巻き戻し
mandel59 Feb 14, 2016
d369b80
Fix translation of enums.md
keiichiw Feb 14, 2016
1d4223b
generate
tatsuya6502 Feb 14, 2016
5d79350
Merge pull request #87 from mandel59/unsafe
KeenS Feb 15, 2016
1f9edc1
generate
tatsuya6502 Feb 15, 2016
7247678
Translate concurrency.md
keiichiw Feb 15, 2016
78c5cf4
Merge branch 'master' into 5_6_concurrency
keiichiw Feb 15, 2016
88df215
In progress
pocket7878 Feb 15, 2016
97bee3e
Merge pull request #29 from KeenS/markdown-syntax-space
tatsuya6502 Feb 15, 2016
b698914
Merge pull request #91 from kw-udon/issue90_scoped
KeenS Feb 15, 2016
7038440
generate
tatsuya6502 Feb 15, 2016
f56c432
translate more
pocket7878 Feb 15, 2016
82e2a9c
Fix translation of concurrency.md
keiichiw Feb 16, 2016
0a915c6
Translate error-handling (part 1)
tatsuya6502 Feb 16, 2016
64e4c9b
Merge pull request #89 from kw-udon/5_6_concurrency
KeenS Feb 16, 2016
457c264
Merge branch 'master' into error-handling-part1
tatsuya6502 Feb 16, 2016
f401943
error-handling - apply review comments and suggestions
tatsuya6502 Feb 16, 2016
75ba8cc
generate
tatsuya6502 Feb 16, 2016
4108206
Merge pull request #92 from tatsuya6502/error-handling-part1
KeenS Feb 17, 2016
18bb5ed
Translate error-handling (part 2)
tatsuya6502 Feb 17, 2016
72da244
generate
tatsuya6502 Feb 17, 2016
4bf8b35
Begin translation of testing
ykomatsu Feb 17, 2016
74fca9c
error-handling - apply review comments and suggestions
tatsuya6502 Feb 17, 2016
b273c3d
Update error-handling:
tatsuya6502 Feb 18, 2016
b267fee
More Translate.
pocket7878 Feb 18, 2016
16d21d7
Update testing
ykomatsu Feb 18, 2016
84027a7
Complete Rough translation
pocket7878 Feb 19, 2016
25d79ed
improve translation.
pocket7878 Feb 19, 2016
441c6f7
Little Polish
pocket7878 Feb 20, 2016
4447374
Update testing
ykomatsu Feb 20, 2016
99219d3
Fix Translation.
pocket7878 Feb 20, 2016
271ffe3
Update TranslationTable
ykomatsu Feb 20, 2016
42ae4cb
error-handling - apply review comments
tatsuya6502 Feb 20, 2016
fa5b6ca
Merge pull request #93 from tatsuya6502/error-handling-part2
tatsuya6502 Feb 20, 2016
ad857e2
Fix translations.
pocket7878 Feb 20, 2016
e46a1a9
Fix translation.
pocket7878 Feb 20, 2016
72781e0
Merge pull request #84 from pocket7878/macro
tatsuya6502 Feb 20, 2016
87796dd
Start translation
pocket7878 Feb 20, 2016
024ce43
Roughly Translated.
pocket7878 Feb 20, 2016
7c0304b
Merge pull request #94 from ykomatsu/testing
tatsuya6502 Feb 20, 2016
9bdb522
Fix Translation.
pocket7878 Feb 21, 2016
cc4bbdf
Merge pull request #96 from pocket7878/inline-assembly
tatsuya6502 Feb 21, 2016
07b67d6
generate
Feb 21, 2016
82807a5
translate borrow-and-asref
dalance Feb 9, 2016
63f26f9
update translation
dalance Feb 21, 2016
100e41b
update TranslationTable
dalance Feb 21, 2016
1e53b2f
Merge branch 'borrow-and-asref' of https://github.com/dalance/the-rus…
dalance Feb 21, 2016
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
6 changes: 3 additions & 3 deletions 1.6/ja/book/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
* [クロージャ](closures.md)
* [共通の関数呼出構文](ufcs.md)
* [クレートとモジュール](crates-and-modules.md)
* [`const``static`](const-and-static.md)
* [`const``static`](const-and-static.md)
* [アトリビュート](attributes.md)
* [`type`エイリアス](type-aliases.md)
* [`type` エイリアス](type-aliases.md)
* [型間のキャスト](casting-between-types.md)
* [関連型](associated-types.md)
* [サイズ不定型](unsized-types.md)
Expand All @@ -48,7 +48,7 @@
* [条件付きコンパイル](conditional-compilation.md)
* [ドキュメント](documentation.md)
* [イテレータ](iterators.md)
* [並行](concurrency.md)
* [並行性](concurrency.md)
* [エラーハンドリング](error-handling.md)
* [保証を選ぶ](choosing-your-guarantees.md)
* [FFI](ffi.md)
Expand Down
30 changes: 15 additions & 15 deletions 1.6/ja/book/advanced-linking.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Rustにおけるリンクの一般的なケースについては本書の前の
<!-- the `link_args` attribute. This attribute is applied to `extern` blocks and -->
<!-- specifies raw flags which need to get passed to the linker when producing an -->
<!-- artifact. An example usage would be: -->
どのようにリンクをカスタマイズするかを`rustc`に指示するために、1つの方法があります。それは、`link_args`アトリビュートを使うことです。
このアトリビュートは`extern`ブロックに適用され、生成物を作るときにリンカに渡したいフラグをそのまま指定します。
どのようにリンクをカスタマイズするかを `rustc` に指示するために、1つの方法があります。それは、 `link_args` アトリビュートを使うことです。
このアトリビュートは `extern` ブロックに適用され、生成物を作るときにリンカに渡したいフラグをそのまま指定します。
使い方の例は次のようになります。

``` no_run
Expand All @@ -34,14 +34,14 @@ extern {}
<!-- LLVM directly to link native libraries, in which case `link_args` will have no -->
<!-- meaning. You can achieve the same effect as the `link_args` attribute with the -->
<!-- `-C link-args` argument to `rustc`. -->
これはリンクを実行するための認められた方法ではないため、この機能は現在`feature(link_args)`ゲートによって隠されているということに注意しましょう。
今は`rustc`がシステムリンカ(多くのシステムでは`gcc`、MSVCでは`link.exe`)に渡すので、追加のコマンドライン引数を提供することには意味がありますが、それが今後もそうだとは限りません。
将来、`rustc`がネイティブライブラリをリンクするためにLLVMを直接使うようになるかもしれませんし、そのような場合には`link_args`は意味がなくなるでしょう。
`rustc``-C link-args`引数をつけることで、`link_args`アトリビュートと同じような効果を得ることができます。
これはリンクを実行するための認められた方法ではないため、この機能は現在 `feature(link_args)` ゲートによって隠されているということに注意しましょう。
今は `rustc` がシステムリンカ(多くのシステムでは `gcc` 、MSVCでは `link.exe` )に渡すので、追加のコマンドライン引数を提供することには意味がありますが、それが今後もそうだとは限りません。
将来、 `rustc` がネイティブライブラリをリンクするためにLLVMを直接使うようになるかもしれませんし、そのような場合には `link_args` は意味がなくなるでしょう。
`rustc``-C link-args` 引数をつけることで、 `link_args` アトリビュートと同じような効果を得ることができます。

<!-- It is highly recommended to *not* use this attribute, and rather use the more -->
<!-- formal `#[link(...)]` attribute on `extern` blocks instead. -->
このアトリビュートは使わ *ない* ことが強く推奨されているので、代わりにもっと正式な`#[link(...)]`アトリビュートを`extern`ブロックに使いましょう。
このアトリビュートは使わ *ない* ことが強く推奨されているので、代わりにもっと正式な `#[link(...)]` アトリビュートを `extern` ブロックに使いましょう。

<!-- # Static linking -->
# スタティックリンク
Expand All @@ -55,7 +55,7 @@ extern {}
<!-- change this and statically link them as well. -->
スタティックリンクとは全ての必要なライブラリを含めた成果物を生成する手順のことで、そうすればコンパイルされたプロジェクトを使いたいシステム全てにライブラリをインストールする必要がなくなります。
Rustのみで構築された依存関係はデフォルトでスタティックリンクされます。そのため、Rustをインストールしなくても、作成されたバイナリやライブラリを使うことができます。
対照的に、ネイティブライブラリ(例えば`libc``libm`)はダイナミックリンクされるのが普通です。しかし、これを変更してそれらを同様にスタティックリンクすることも可能です。
対照的に、ネイティブライブラリ(例えば `libc``libm` )はダイナミックリンクされるのが普通です。しかし、これを変更してそれらを同様にスタティックリンクすることも可能です。

<!-- Linking is a very platform-dependent topic, and static linking may not even be -->
<!-- possible on some platforms! This section assumes some basic familiarity with -->
Expand All @@ -69,8 +69,8 @@ Rustのみで構築された依存関係はデフォルトでスタティック
<!-- By default, all Rust programs on Linux will link to the system `libc` along with -->
<!-- a number of other libraries. Let's look at an example on a 64-bit Linux machine -->
<!-- with GCC and `glibc` (by far the most common `libc` on Linux): -->
デフォルトでは、Linux上の全てのRustのプログラムはシステムの`libc`とその他のいくつものライブラリとリンクされます。
GCCと`glibc`(Linuxにおける最も一般的な`libc`)を使った64ビットLinuxマシンでの例を見てみましょう。
デフォルトでは、Linux上の全てのRustのプログラムはシステムの `libc` とその他のいくつものライブラリとリンクされます。
GCCと `glibc` (Linuxにおける最も一般的な `libc` )を使った64ビットLinuxマシンでの例を見てみましょう。

``` text
$ cat example.rs
Expand All @@ -95,8 +95,8 @@ $ ldd example
<!-- Static linking is supported via an alternative `libc`, [`musl`](http://www.musl-libc.org). You can compile -->
<!-- your own version of Rust with `musl` enabled and install it into a custom -->
<!-- directory with the instructions below: -->
スタティックリンクは代わりの`libc`である[`musl`](http://www.musl-libc.org/)によってサポートされています。
以下の手順に従い、`musl`を有効にした独自バージョンのRustをコンパイルして独自のディレクトリにインストールすることができます。
スタティックリンクは代わりの `libc` である [`musl`](http://www.musl-libc.org/) によってサポートされています。
以下の手順に従い、 `musl` を有効にした独自バージョンのRustをコンパイルして独自のディレクトリにインストールすることができます。

```text
$ mkdir musldist
Expand Down Expand Up @@ -142,7 +142,7 @@ $ du -h musldist/bin/rustc
<!-- You now have a build of a `musl`-enabled Rust! Because we've installed it to a -->
<!-- custom prefix we need to make sure our system can find the binaries and appropriate -->
<!-- libraries when we try and run it: -->
これで`musl`が有効になったRustのビルドが手に入りました!
これで `musl` が有効になったRustのビルドが手に入りました!
独自のプレフィックスを付けてインストールしたので、試しに実行するときにはシステムがバイナリと適切なライブラリを見付けられることを確かめなければなりません。

```text
Expand Down Expand Up @@ -171,5 +171,5 @@ thread '<main>' panicked at 'failed', example.rs:1
<!-- `cargo build` also permits the `--target` option so you should be able to build -->
<!-- your crates as normal. However, you may need to recompile your native libraries -->
<!-- against `musl` before they can be linked against. -->
`cargo build``--target`オプションを受け付けるので、あなたのクレートも普通にビルドできるはずです。
ただし、リンクする前にネイティブライブラリを`musl`向けにリコンパイルする必要はあるかもしれません。
`cargo build``--target` オプションを受け付けるので、あなたのクレートも普通にビルドできるはずです。
ただし、リンクする前にネイティブライブラリを `musl` 向けにリコンパイルする必要はあるかもしれません。
74 changes: 45 additions & 29 deletions 1.6/ja/book/borrow-and-asref.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
% Borrow and AsRef
% BorrowとAsRef
<!-- % Borrow and AsRef -->

The [`Borrow`][borrow] and [`AsRef`][asref] traits are very similar, but
different. Here’s a quick refresher on what these two traits mean.
<!-- The [`Borrow`][borrow] and [`AsRef`][asref] traits are very similar, but -->
<!-- different. Here’s a quick refresher on what these two traits mean. -->
[`Borrow`][borrow] トレイトと [`AsRef`][asref] トレイトはとてもよく似ていますが違うものです。ここでは2つのトレイトの意味を簡単に説明します。

[borrow]: ../std/borrow/trait.Borrow.html
[asref]: ../std/convert/trait.AsRef.html

<!-- # Borrow -->
# Borrow

The `Borrow` trait is used when you’re writing a datastructure, and you want to
use either an owned or borrowed type as synonymous for some purpose.
<!-- The `Borrow` trait is used when you’re writing a datastructure, and you want to -->
<!-- use either an owned or borrowed type as synonymous for some purpose. -->
`Borrow` トレイトはデータ構造を書いていて、所有型と借用型を同等に扱いたいときに使います。

For example, [`HashMap`][hashmap] has a [`get` method][get] which uses `Borrow`:
<!-- For example, [`HashMap`][hashmap] has a [`get` method][get] which uses `Borrow`: -->
例えば、 [`HashMap`][hashmap] には `Borrow` を使った [`get` メソッド][get] があります。

```rust,ignore
fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
Expand All @@ -22,17 +27,19 @@ fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
[hashmap]: ../std/collections/struct.HashMap.html
[get]: ../std/collections/struct.HashMap.html#method.get

This signature is pretty complicated. The `K` parameter is what we’re interested
in here. It refers to a parameter of the `HashMap` itself:
<!-- This signature is pretty complicated. The `K` parameter is what we’re interested -->
<!-- in here. It refers to a parameter of the `HashMap` itself: -->
このシグネチャは少し複雑です。`K` パラメータに注目してください。これは以下のように `HashMap` 自身のパラメータになっています。

```rust,ignore
struct HashMap<K, V, S = RandomState> {
```

The `K` parameter is the type of _key_ the `HashMap` uses. So, looking at
the signature of `get()` again, we can use `get()` when the key implements
`Borrow<Q>`. That way, we can make a `HashMap` which uses `String` keys,
but use `&str`s when we’re searching:
<!-- The `K` parameter is the type of _key_ the `HashMap` uses. So, looking at -->
<!-- the signature of `get()` again, we can use `get()` when the key implements -->
<!-- `Borrow<Q>`. That way, we can make a `HashMap` which uses `String` keys, -->
<!-- but use `&str`s when we’re searching: -->
`K` パラメータは `HashMap` の「キー」を表す型です。ここで再び `get()` のシグネチャを見ると、キーが `Borrow<Q>` を実装しているときに `get()` を使えることが分かります。そのため、以下のように `String` をキーとした `HashMap` を検索するときに `&str` を使うことができます。

```rust
use std::collections::HashMap;
Expand All @@ -43,13 +50,15 @@ map.insert("Foo".to_string(), 42);
assert_eq!(map.get("Foo"), Some(&42));
```

This is because the standard library has `impl Borrow<str> for String`.
<!-- This is because the standard library has `impl Borrow<str> for String`. -->
これは標準ライブラリが `impl Borrow<str> for String` を提供しているためです。

For most types, when you want to take an owned or borrowed type, a `&T` is
enough. But one area where `Borrow` is effective is when there’s more than one
kind of borrowed value. This is especially true of references and slices: you
can have both an `&T` or a `&mut T`. If we wanted to accept both of these types,
`Borrow` is up for it:
<!-- For most types, when you want to take an owned or borrowed type, a `&T` is -->
<!-- enough. But one area where `Borrow` is effective is when there’s more than one -->
<!-- kind of borrowed value. This is especially true of references and slices: you -->
<!-- can have both an `&T` or a `&mut T`. If we wanted to accept both of these types, -->
<!-- `Borrow` is up for it: -->
所有型か借用型のどちらかを取りたい場合、たいていは `&T` で十分ですが、借用された値が複数種類ある場合 `Borrow` が役に立ちます。特に参照とスライスは `&T` と `&mut T` のいずれも取りうるため、そのどちらも受け入れたい場合は `Borrow` がよいでしょう。

```rust
use std::borrow::Borrow;
Expand All @@ -65,12 +74,15 @@ foo(&i);
foo(&mut i);
```

This will print out `a is borrowed: 5` twice.
<!-- This will print out `a is borrowed: 5` twice. -->
上のコードは `a is borrowed: 5` を二度出力します。

<!-- # AsRef -->
# AsRef

The `AsRef` trait is a conversion trait. It’s used for converting some value to
a reference in generic code. Like this:
<!-- The `AsRef` trait is a conversion trait. It’s used for converting some value to -->
<!-- a reference in generic code. Like this: -->
`AsRef` トレイトは変換用のトレイトです。ジェネリックなコードにおいて、値を参照に変換したい場合に使います。

```rust
let s = "Hello".to_string();
Expand All @@ -80,14 +92,18 @@ fn foo<T: AsRef<str>>(s: T) {
}
```

# Which should I use?
<!-- # Which should I use? -->
# どちらを使うべきか

We can see how they’re kind of the same: they both deal with owned and borrowed
versions of some type. However, they’re a bit different.
<!-- We can see how they’re kind of the same: they both deal with owned and borrowed -->
<!-- versions of some type. However, they’re a bit different. -->
ここまでで見てきた通り、2つのトレイトは、どちらもある型の所有型バージョンと借用型バージョンの両方を扱う、という意味で同じような種類のものですが、少し違います。

Choose `Borrow` when you want to abstract over different kinds of borrowing, or
when you’re building a datastructure that treats owned and borrowed values in
equivalent ways, such as hashing and comparison.
<!-- Choose `Borrow` when you want to abstract over different kinds of borrowing, or -->
<!-- when you’re building a datastructure that treats owned and borrowed values in -->
<!-- equivalent ways, such as hashing and comparison. -->
いくつかの異なる種類の借用を抽象化したい場合や、ハッシュ化や比較のために所有型と借用型を同等に扱いたいデータ構造を作る場合は `Borrow` を使ってください。

Choose `AsRef` when you want to convert something to a reference directly, and
you’re writing generic code.
<!-- Choose `AsRef` when you want to convert something to a reference directly, and -->
<!-- you’re writing generic code. -->
ジェネリックなコードで値を参照に直接変換したい場合は `AsRef` を使ってください。
Loading