You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -568,10 +568,10 @@ Not compatibly, no, because they would no longer have a named associated type. T
568
568
569
569
Generally yes, but all impls would have to be rewritten to include the definition of the associated type. In many cases, some form of type-alias impl trait (or impl trait in associated type values) would also be required.
570
570
571
-
For example, if we changed the `IntoIntIterator` trait from the motivation to use an explicit associated type..
571
+
For example, if we changed the `IntoNumIterator` trait from the motivation to use an explicit associated type..
572
572
573
573
```rust
574
-
traitIntoIntIterator {
574
+
traitIntoNumIterator {
575
575
typeIntIter:Iterator<Item=u32>;
576
576
fninto_iter(self) ->Self::IntIter;
577
577
}
@@ -580,7 +580,7 @@ trait IntoIntIterator {
580
580
...then impls like...
581
581
582
582
```rust
583
-
implIntoIntIteratorforMyType {
583
+
implIntoNumIteratorforMyType {
584
584
fninto_int_iter(self) ->implIterator<Item=u32> {
585
585
(0..self.len()).map(|x|x*2)
586
586
}
@@ -591,7 +591,7 @@ impl IntoIntIterator for MyType {
591
591
592
592
### Would there be any way to make it possible to migrate from `impl Trait` to a named associated type compatibly?
593
593
594
-
Potentially! There have been proposals to allow the values of associated types that appear in function return types to be inferred from the function declaration. So, using the example from the previous question, the impl for `IntoIntIterator` could infer the value of `IntIter` based on the return type of `into_int_iter`. This may be a good idea, but it is not proposed as part of this RFC.
594
+
Potentially! There have been proposals to allow the values of associated types that appear in function return types to be inferred from the function declaration. So, using the example from the previous question, the impl for `IntoNumIterator` could infer the value of `IntIter` based on the return type of `into_int_iter`. This may be a good idea, but it is not proposed as part of this RFC.
595
595
596
596
### What about using an implicitly-defined associated type?
597
597
@@ -657,7 +657,7 @@ There are a number of crates that do desugaring like this manually or with proce
657
657
658
658
### Namingreturn types
659
659
660
-
ThisRFC does not include a way for generic code to name or bound the result of `->implTrait` return types.This means, for example, that for the `IntoIntIterator` trait introduced in the motivation, it is not possible to write a function that takes a `T:IntoIntIterator` which returns an `ExactLenIterator`; forasyncfunctions, themostcommontimethiscomesupiscodethatwishestotakeanasyncfunctionthatreturnsa `Send` future.WeexpectfutureRFCswilladdresstheseuse cases.
660
+
ThisRFC does not include a way for generic code to name or bound the result of `->implTrait` return types.This means, for example, that for the `IntoNumIterator` trait introduced in the motivation, it is not possible to write a function that takes a `T:IntoNumIterator` which returns an `ExactLenIterator`; forasyncfunctions, themostcommontimethiscomesupiscodethatwishestotakeanasyncfunctionthatreturnsa `Send` future.WeexpectfutureRFCswilladdresstheseuse cases.
0 commit comments