I'm not sure if it is design issue or compiler issue (or between chair and keyboard). I tried to write following code:
#![feature(generic_associated_types)]
trait Foo
{
type VecContent;
type Assoc<'a>
where
Self::Assoc<'a>: 'a;
fn get_foo<'a>(&'a self, bar: &'a std::vec::Vec<Self::VecContent>) -> Self::Assoc<'a>
where
Self::Assoc<'a>: 'a;
}
struct Bar<T> {
bar: std::vec::Vec<T>
}
struct BarAssoc<'a, T> {
bar: &'a std::vec::Vec<T>
}
impl<T> Foo for Bar<T>
{
type Assoc<'a>
where
T: 'a
= BarAssoc<'a, T>;
fn get_foo<'a>(&'a self) -> Self::Assoc<'a>
where
T: 'a
{
unimplemented!()
}
}
However I get errors:
Compiling playground v0.0.1 (/playground)
error[E0275]: overflow evaluating the requirement `<Bar<T> as Foo>::Assoc<'a> == _`
--> src/lib.rs:28:8
|
28 | fn get_foo<'a>(&'a self) -> Self::Assoc<'a>
| ^^^^^^^
For more information about this error, try `rustc --explain E0275`.
error: could not compile `playground` due to previous error
Any idea if it is:
- Wrong code
- Compiler bug (GATs are not fully implemented yet AFAIK)
- Design issue (GATs are not full highier-order kinds)