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:
318318fn foo(&'a str) -> usize;
319319```
320320
321+ <!--
321322This signature claims that it can handle any `&str` that lives at least as
322323long as `'a`. Now if this signature was variant over `&'a str`, that
323324would mean
325+ -->
326+
327+ このシグネチャは、少なくとも ` 'a ` は生きる、いかなる ` &str ` も扱うことができると
328+ 主張します。この時、もしシグネチャが ` &'a str ` において変性であるならば、これは
329+ 次のシグネチャ
324330
325331``` rust,ignore
326332fn foo(&'static str) -> usize;
327333```
328334
335+ <!--
329336could be provided in its place, as it would be a subtype. However this function
330337has a stronger requirement: it says that it can only handle `&'static str`s,
331338and nothing else. Giving `&'a str`s to it would be unsound, as it's free to
332339assume that what it's given lives forever. Therefore functions are not variant
333340over their arguments.
341+ -->
342+
343+ が同じ場所に現れうるということを意味するでしょう。 ` &'static str ` が派生型だからです。
344+ しかし、この関数にはより強い要件があります。 ` &'static str ` のみを扱い、他のものは
345+ 扱わないということです。 ` &'a str ` などを渡すと健全ではなくなるでしょう。
346+ なぜなら、この関数シグネチャは自由に、渡されたものが永遠に生きると見なすことが
347+ できるからです。
348+ それゆえに、関数はその引数において、変性ではないのです。
334349
335350To see why ` Fn(T) -> U ` should be variant over U, consider the following
336351function signature:
You can’t perform that action at this time.
0 commit comments