Context-Generic Programming
banner
contextgeneric.dev
Context-Generic Programming
@contextgeneric.dev
A new modular paradigm for Rust. Project account managed by @maybevoid.com. More info at https://contextgeneric.dev/
In short, cgp-serde extends Serde’s original Serialize and Deserialize traits with CGP, making it possible to write overlapping or orphaned implementations of these traits and thus bypass the standard Rust coherence restrictions.
November 3, 2025 at 1:15 PM
Through the extensible visitor pattern, you will see how to build a modular interpreter for a simple math expression language, complete with evaluation handlers that can be reused across different language versions.
July 10, 2025 at 1:53 PM
This also enables safe enum upcasting and downcasting, as well as modular builder and visitor patterns in Rust. Check out the blog post to find out more!
July 7, 2025 at 2:00 PM
Also note that preset is an advanced concept in CGP that is yet to be formally introduced in our book. More updates will be coming very soon. But for now, you can check out the PR for a very high level overview of the changes: github.com/contextgener....
Preset Macro Improvements by soareschen · Pull Request #91 · contextgeneric/cgp
Summary This PR brings a number of improvements to the CGP Presets feature, and adds better support on OOP-like inheritance on presets. Inheritance Presets can now inherit from each other a short h...
github.com
May 3, 2025 at 8:31 PM
Now before you start wondering or getting disgusted, the inheritance in CGP is quite different from the classical inheritance in the OOP world. CGP presets are more like type-level dictionaries of generic mixins. So in a way, preset inheritance is sort of like extending type-level lookup tables.
May 3, 2025 at 8:31 PM
There are also many other advanced improvements, such as allowing PhantomData tags and generic implementation of field accessors using AsRef.

The PR covers high level overview of all changes. For detailed walk through, stay tuned for more blog posts and updates on the book.
March 23, 2025 at 4:45 PM
This mainly improves use of CGP with idiomatic Rust code. Apparently, some readers pointed out about the aesthetic of getter methods returning &String instead of &str. This especially affects first impressions, when the hello world of CGP demonstrates the dependency injection of string fields.
March 23, 2025 at 4:45 PM
We are in the progress of writing a full blog post detailing all new features, as well as updating the CGP Patterns book to include the new features. Hopefully this will all be done in a few more weekends!
March 9, 2025 at 9:46 PM