Constraining Generics?

23 views
Skip to first unread message

Jeremy Steward

unread,
Oct 12, 2021, 1:26:44 PMOct 12
to Cap'n Proto

Hi Kenton / all,

I'm trying to do something akin to:

struct SomeGeneric(T) {
    data @0 :List(T);
   
    // other fields...
}

Of course, I run into the fact that List(AnyPointer) is not supported. However, I don't want _any_ pointer. I'd be fine with only supporting types that List supports. Is there no way to annotate / constrain the type T above? Other threads in the past have suggested making an intermediate struct at the cost of extra pointer indirection, but I'm pretty sure I only ever want a struct in the T position. Is this possible?

Cheers,
Reply all
Reply to author
Forward
0 new messages