Show HN: Inception: Automatic Rust Trait Implementation by Induction

4 bietroi 0 9/6/2025, 4:01:32 AM github.com ↗
Hi HN,

I thought this would be a good place to share a little puzzle I've been working on. Inception is a Rust library that helps you share behaviors in Rust using structural induction. Practically, this means that instead of having a derive macro for each behavior, a single derive can be used to enable any number of behaviors. It doesn't do this using runtime reflection, but rather type-level programming - so there is monomorphization across the substructures, and (at least in theory) no greater overhead than with macro expansion.

While there are a lot of things missing still and the current implementation is very suboptimal, I'd say it proves the general concept for common structures. Examples of Clone/Eq/Hash/etc replicas implemented in this way are provided.

The code is not idiomatic, which is my biggest reservation about continuing this work. It was fun to prove, but is not so fun to _improve_, as it feels a bit like swimming upstream. In any case I hope some of you find it interesting!

Comments (0)

No comments yet