You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/2025-07-07-extensible-datatypes-part-1.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ authors = ["Soares Chen"]
8
8
9
9
# Overview
10
10
11
-
I’m excited to announce the release of **CGP v0.4.2**, a major milestone that significantly expands the expressive power of generic programming in Rust. With this release, CGP introduces full support for **extensible records and variants**, unlocking a range of new capabilities for developers working with highly modular and reusable code.
11
+
I’m excited to announce the release of [**CGP v0.4.2**](https://github.com/contextgeneric/cgp/releases/tag/v0.4.2), a major milestone that significantly expands the expressive power of generic programming in Rust. With this release, CGP introduces full support for **extensible records and variants**, unlocking a range of new capabilities for developers working with highly modular and reusable code.
12
12
13
13
Extensible records and variants allow developers to write code that operates on *any struct containing specific fields* or *any enum containing specific variants*, regardless of their complete definition. This makes it possible to write truly generic and flexible logic that is decoupled from rigid type definitions.
14
14
@@ -30,7 +30,7 @@ Here is a revised version of your “Content Organization” section, rewritten
30
30
31
31
This article is the first in a five-part series exploring the examples and implementation of extensible data types in CGP. Below is an overview of what each part covers:
32
32
33
-
**Part 1: Highlights and Extensible Records Demo** – In this introductory part, we present a high-level overview of the key features enabled by extensible data types. We then dive into a hands-on demonstration showing how extensible records can be used to build and compose modular builders for real-world applications.
33
+
**Part 1: Highlights and Extensible Records Demo**(this post) – In this introductory part, we present a high-level overview of the key features enabled by extensible data types. We then dive into a hands-on demonstration showing how extensible records can be used to build and compose modular builders for real-world applications.
34
34
35
35
**Part 2: Extensible Variants Demo** – This part continues the demonstration by introducing extensible variants. We use them to address the [**expression problem**](https://en.wikipedia.org/wiki/Expression_problem), implementing a set of reusable interpreter components for a small toy language.
36
36
@@ -176,7 +176,7 @@ let employee = Employee::builder()
176
176
.finalize_build();
177
177
```
178
178
179
-
Here’s what’s happening: The `builder()` method on `Employee` initiates a *partial record* builder, an intermediate structure that initially contains none of the target fields. Each call to `build_from` takes a struct that contributes one or more of the remaining fields and returns a new builder with those fields filled in. Once all required fields have been supplied, the `finalize_build()` method consumes the builder and produces a fully constructed `FooBarBaz` instance.
179
+
Here’s what’s happening: The `builder()` method on `Employee` initiates a *partial record* builder, an intermediate structure that initially contains none of the target fields. Each call to `build_from` takes a struct that contributes one or more of the remaining fields and returns a new builder with those fields filled in. Once all required fields have been supplied, the `finalize_build()` method consumes the builder and produces a fully constructed `Employee` instance.
180
180
181
181
Just like enum upcasting and downcasting, the struct builder is implemented entirely in **safe**, **panic-free** Rust. There’s no runtime reflection or unsafe code involved. The only requirement is that the participating structs must have compatible fields and derive the CGP-provided traits `HasFields` and `BuildField`.
182
182
@@ -331,7 +331,7 @@ This opens the door to a new style of constructor logic: one that is **modular**
331
331
332
332
# Extensible Builders
333
333
334
-
In this section, we’ll revisit the constructor examples we’ve already seen — and show how to rewrite them using CGP’s new builder pattern to achieve clean, modular, and reusable construction logic.
334
+
In this section, we’ll revisit the constructor examples we’ve already seen — and show how to rewrite them using CGP’s new builder pattern to achieve clean, modular, and reusable construction logic. A full version of the example code covered in this section is available on our [GitHub repository](https://github.com/contextgeneric/cgp-examples/tree/main/builder)
Copy file name to clipboardExpand all lines: content/hire.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ weight = 2
10
10
11
11
## Who I Am
12
12
13
-
Hi! 👋 I’m **Soares Chen** (a.k.a. [@MaybeVoid](#)), the **creator of Context-Generic Programming (CGP)** and a passionate **Rust Engineer**. I'm currently looking for **new opportunities** to contribute to impactful software projects. You can view my [CV](#) and contact me at [[email protected]](mailto:[email protected]).
13
+
Hi! 👋 I’m **Soares Chen** (a.k.a. [@MaybeVoid](#)), the **creator of Context-Generic Programming (CGP)** and a passionate **Rust Engineer**. I'm currently looking for **new opportunities** to contribute to impactful software projects. You can view my [CV](/cv-soareschen-2025-07.pdf) and contact me at [[email protected]](mailto:[email protected]).
0 commit comments