File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -318,19 +318,34 @@ signature:
318
318
fn foo(&'a str) -> usize;
319
319
```
320
320
321
+ <!--
321
322
This signature claims that it can handle any `&str` that lives at least as
322
323
long as `'a`. Now if this signature was variant over `&'a str`, that
323
324
would mean
325
+ -->
326
+
327
+ このシグネチャは、少なくとも ` 'a ` は生きる、いかなる ` &str ` も扱うことができると
328
+ 主張します。この時、もしシグネチャが ` &'a str ` において変性であるならば、これは
329
+ 次のシグネチャ
324
330
325
331
``` rust,ignore
326
332
fn foo(&'static str) -> usize;
327
333
```
328
334
335
+ <!--
329
336
could be provided in its place, as it would be a subtype. However this function
330
337
has a stronger requirement: it says that it can only handle `&'static str`s,
331
338
and nothing else. Giving `&'a str`s to it would be unsound, as it's free to
332
339
assume that what it's given lives forever. Therefore functions are not variant
333
340
over their arguments.
341
+ -->
342
+
343
+ が同じ場所に現れうるということを意味するでしょう。 ` &'static str ` が派生型だからです。
344
+ しかし、この関数にはより強い要件があります。 ` &'static str ` のみを扱い、他のものは
345
+ 扱わないということです。 ` &'a str ` などを渡すと健全ではなくなるでしょう。
346
+ なぜなら、この関数シグネチャは自由に、渡されたものが永遠に生きると見なすことが
347
+ できるからです。
348
+ それゆえに、関数はその引数において、変性ではないのです。
334
349
335
350
To see why ` Fn(T) -> U ` should be variant over U, consider the following
336
351
function signature:
You can’t perform that action at this time.
0 commit comments