Skip to content

Commit 460dac5

Browse files
committed
Translate paraghs
1 parent bb7243d commit 460dac5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/subtyping.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,34 @@ signature:
318318
fn foo(&'a str) -> usize;
319319
```
320320

321+
<!--
321322
This signature claims that it can handle any `&str` that lives at least as
322323
long as `'a`. Now if this signature was variant over `&'a str`, that
323324
would mean
325+
-->
326+
327+
このシグネチャは、少なくとも `'a` は生きる、いかなる `&str` も扱うことができると
328+
主張します。この時、もしシグネチャが `&'a str` において変性であるならば、これは
329+
次のシグネチャ
324330

325331
```rust,ignore
326332
fn foo(&'static str) -> usize;
327333
```
328334

335+
<!--
329336
could be provided in its place, as it would be a subtype. However this function
330337
has a stronger requirement: it says that it can only handle `&'static str`s,
331338
and nothing else. Giving `&'a str`s to it would be unsound, as it's free to
332339
assume that what it's given lives forever. Therefore functions are not variant
333340
over their arguments.
341+
-->
342+
343+
が同じ場所に現れうるということを意味するでしょう。 `&'static str` が派生型だからです。
344+
しかし、この関数にはより強い要件があります。 `&'static str` のみを扱い、他のものは
345+
扱わないということです。 `&'a str` などを渡すと健全ではなくなるでしょう。
346+
なぜなら、この関数シグネチャは自由に、渡されたものが永遠に生きると見なすことが
347+
できるからです。
348+
それゆえに、関数はその引数において、変性ではないのです。
334349

335350
To see why `Fn(T) -> U` should be variant over U, consider the following
336351
function signature:

0 commit comments

Comments
 (0)