Following the announcement of GATs being no longer "incomplete". I thought I might see if I could use it to make an equivalent of the single linked list that is generic in the pointer type (so it can be used with both Rc and Arc). Unfortunately, it is more difficult than I had hoped, and might be impossible. My initial attempt was Rust Playground
Unfortunately, I got an error for overflow evaluating the requirement
for the Sized
trait. With some more constraints, I was able to get the Node
type to compile, but when I try to instantiate I get an ICE (Rust Playground, ICE reported at ICE with recursive type using GAT. · Issue #87750 · rust-lang/rust · GitHub).
So my questions are:
- Is there some way to get this to work?
- If not, is it worth exploring a way to support doing things like this?
FWIW, I also tried doing something similar without GAT, and was able to get something that seems to work, although it is less elagant: Rust Playground.