Compiling playground v0.0.1 (/playground)
error[E0275]: overflow evaluating the requirement `&_: std::marker::Sized`
|
= help: consider adding a `#![recursion_limit="10"]` attribute to your crate
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&_`
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&Join<_>`
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&Join<Join<_>>`
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&Join<Join<Join<_>>>`
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&Join<Join<Join<Join<_>>>>`
Is it the problem related to the constructor <&'a T as IntoIterator>::IntoIter?
Could be it a bug?
I'm wandering if it is related in same way with some wrong logic related to the reference &T and the as operator.
This line is the problem. Rust will only search so deep recursively so that compilation ends, because of this it can't handle recursive definitions that well in some cases. Try and use type erasure to solve this. That can be done with trait objects.
Also to me at first seemed a recursive definition.
But now what I not understand is why the compiler search recursively.
This code use generics and T could be anything, not only Join<T>, for example could be Vec<T>: in this case there is no recursion at all.
Moreover in the code above there isn't any Join monomorphization driven by explicit Join usage like let join: Join<Vec<i32>>, so what is trying to resolve the compiler?
It is searching recursively to find out what the type of IntoIter is. This is because Rust makes sure that traits are valid when they are defined rather than when they are used, like C++. There is work for lazy normalization, which may solve this problem.