Problem with GAT chaining and lifetimes

We have a problem with GAT chaining in which the intermediate step have lifetimes, but the last one does not. We would like to define an associated type by following the chain, but that type does not have a lifetime.

Here we have a supplier for Read and a supplier for Deserializer. The Supply trait has a lifetime, as, for example, the Read might read from a shared read-only memory section. However, when definind the structure S we simply want S::Assoc to be the DeserType of the Deserializer.

The code above compiles (albeit other lifetime problems might arise when it is used), but we would like to get read of the type parameter A and just derive the DeserType using a chain of associated types.

Suggestions?

A doesn't need to be a type parameter of S if you remove the bounds from the struct.

Or if you need it at the declaration, for example as a field, you can go through C.

I also checked nothing beyond compilation in the above playgrounds.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.