Idea: object-safe static trait methods

That function would fail to compile, because in that context, where T: ?Sized, <T as Trait>::associated_function would require an extra argument, something with metadata for T. I guess the type of <T as Trait>::associated_function would be fn (*const T, i32), or with the custom DST stuff we’ve been talking about in Pre-eRFC: Let’s fix DSTs, <T as Referent>::Meta. In that case, I’m assuming &T and *const T would have to coerce to T::Meta, so you could call Trait::associated_function() with &T as a the first argument.

But wait… now that I think about it, that would be backward incompatible and silly. Because then <[T] as Trait>::associated_function would now require an extra argument.

1 Like