Skip to content

Commit 7d2c11f

Browse files
committed
Minor edit
1 parent cea85f6 commit 7d2c11f

File tree

2 files changed

+3
-36
lines changed

2 files changed

+3
-36
lines changed

code/src/lib.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +0,0 @@
1-
use cgp::prelude::*;
2-
3-
#[cgp_getter {
4-
provider: NameGetter,
5-
}]
6-
pub trait HasName {
7-
fn name(&self) -> &String;
8-
}
9-
10-
#[derive(HasField)]
11-
pub struct Person {
12-
pub name: String,
13-
}
14-
15-
pub struct PersonComponents;
16-
17-
impl HasComponents for Person {
18-
type Components = PersonComponents;
19-
}
20-
21-
delegate_components! {
22-
PersonComponents {
23-
NameGetterComponent: UseFields,
24-
}
25-
}
26-
27-
fn main() {
28-
let person = Person {
29-
name: "Alice".into(),
30-
};
31-
32-
println!("Hello, {}", person.name());
33-
}

content/blog/2025-01-09-v0.3.0-release.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title = "CGP Updates: v0.3.0 Release and New Chapters"
66

77
# Summary
88

9-
We’re excited to announce the release of [v0.3.0](https://github.com/contextgeneric/cgp/releases/tag/v0.3.0) of the [`cgp`](https://docs.rs/cgp/0.3.0/cgp/) crate, along with several [new](https://patterns.contextgeneric.dev/error-handling.html) [chapters](https://patterns.contextgeneric.dev/field-accessors.html) of the [CGP Patterns](https://patterns.contextgeneric.dev/) book book! This post highlights some of the key features and updates included in this release.
9+
We’re excited to announce the release of [v0.3.0](https://github.com/contextgeneric/cgp/releases/tag/v0.3.0) of the [`cgp`](https://docs.rs/cgp/0.3.0/cgp/) crate, along with several [new](https://patterns.contextgeneric.dev/error-handling.html) [chapters](https://patterns.contextgeneric.dev/field-accessors.html) of the [CGP Patterns](https://patterns.contextgeneric.dev/) book! This post highlights some of the key features and updates included in this release.
1010

1111
# New Book Chapters
1212

@@ -16,7 +16,7 @@ We’ve added a few new chapters to the [CGP Patterns](https://patterns.contextg
1616

1717
In the [launch announcement](/blog/early-preview-announcement/) for CGP, some readers remarked that CGP seemed to be primarily a dependency injection framework in Rust. While this observation captured part of its functionality, a key feature not yet covered was CGP's ability to use _abstract types_ in conjunction with the dependency injection of _types_.
1818

19-
In the [new chapter](https://patterns.contextgeneric.dev/associated-types.html) of the book, we explore this powerful feature with a motivating example: implementing a context-generic authentication token validator that is not only generic over the `Context` but also over abstract `Time` and `AuthToken` types. The chapter demonstrates how to use the `cgp_type!` macro to streamline the declaration of abstract type traits and how to employ `UseType` in component wiring to instantiate abstract types.
19+
In the [new chapter](https://patterns.contextgeneric.dev/associated-types.html) of the book, we explore this powerful feature with a motivating example: implementing a context-generic authentication token validator that is not only generic over the `Context` but also over abstract `Time` and `AuthToken` types. The chapter also demonstrates how to use the `cgp_type!` macro to streamline the declaration of abstract type traits and how to employ `UseType` in component wiring to instantiate abstract types.
2020

2121
## Error Handling
2222

@@ -91,7 +91,7 @@ fn main() {
9191
}
9292
```
9393

94-
In this example, the `Person` struct derives the `HasField` trait, which automatically implements the `HasName` trait without any additional code. This enables traits like `HasName` to be defined in separate crates or modules while still being automatically implemented for any struct that derives `HasField` with the necessary fields.
94+
In this example, the `Person` struct derives the `HasField` trait, which automatically implements the `HasName` trait without any additional code. This means that an accessor trait like `HasName` can be defined in separate crates or modules, and it will still be automatically implemented for all structs that derive `HasField` with the necessary fields.
9595

9696
For more details on `#[cgp_auto_getter]`, refer to the [Generic Accessor Providers](https://patterns.contextgeneric.dev/generic-accessor-providers.html#the-cgp_auto_getter-macro) chapter in the CGP Patterns book.
9797

0 commit comments

Comments
 (0)