Skip to content

Commit d4a82f2

Browse files
committed
AI-revise remaining sections
1 parent dcb05ba commit d4a82f2

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

content/blog/2025-10-12-v0.5.0-release.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,11 @@ For existing users who wish to continue using the original `HasInner` trait with
581581

582582
# Improvements
583583

584-
A couple of improvements have been made for the existing constructs in CGP. Here are a few highlights.
584+
Several improvements have been made to existing constructs in CGP. Here are some highlights.
585585

586586
## Allow non-self argument in getter methods
587587

588-
It is now possible to use `#[cgp_getter]` and `#[cgp_auto_getter]` with types other than `Self` as the target. For example, you can now use it on a trait like:
588+
It is now possible to use `#[cgp_getter]` and `#[cgp_auto_getter]` with target types other than `Self`. For example, you can now define a trait like:
589589

590590
```rust
591591
#[cgp_getter]
@@ -594,11 +594,11 @@ pub trait HasFooBar: HasFooType + HasBarType {
594594
}
595595
```
596596

597-
With this, the provider `UseField<Symbol!("bar")>` would implement `FooBarGetter<Context>`, if `Context::Foo` implements `HasField<Symbol!("bar")>, Value = Context::Bar>`.
597+
With this, the provider `UseField<Symbol!("bar")>` would implement `FooBarGetter<Context>` if `Context::Foo` implements `HasField<Symbol!("bar"), Value = Context::Bar>`.
598598

599599
## Support use of lifetime parameters inside CGP traits
600600

601-
You can now include lifetimes inside the component trait parameters. For example, `cgp-serde` defines a component that corresponds to `serde`'s `Deserialize` as follows:
601+
Lifetimes can now be included inside component trait parameters. For instance, `cgp-serde` defines a component corresponding to `serde`'s `Deserialize` as follows:
602602

603603
```rust
604604
#[cgp_component {
@@ -612,13 +612,13 @@ pub trait CanDeserializeValue<'de, Value> {
612612
}
613613
```
614614

615-
Inside the type parameters of `IsProviderFor`, the lifetime `'de` is captured as `Life<'de>`, which is defined as:
615+
Within the type parameters of `IsProviderFor`, the lifetime `'de` is captured as `Life<'de>`, which is defined as:
616616

617617
```rust
618618
pub struct Life<'a>(pub PhantomData<*mut &'a ()>);
619619
```
620620

621-
Using `Life`, we can refer to the lifetime inside of `check_components!`, such as:
621+
Using `Life`, the lifetime can be referred to inside `check_components!`, as in the following example:
622622

623623
```rust
624624
check_components! {
@@ -631,9 +631,9 @@ check_components! {
631631
}
632632
```
633633

634-
## Allow shortcut for overriding provider names in `#[cgp_type]` and `#[cgp_getter]`
634+
## Shortcut for overriding provider names in `#[cgp_type]` and `#[cgp_getter]`
635635

636-
If you want to customize only the name of the provider trait in `#[cgp_type]` and `#[cgp_getter]`, you can now specify them directly without using the fully qualified key-value syntax.
636+
You can now customize only the name of the provider trait in `#[cgp_type]` and `#[cgp_getter]` without using the fully qualified key-value syntax.
637637

638638
For example:
639639

@@ -672,11 +672,11 @@ pub trait HasFoo: HasFooType {
672672

673673
# Bug Fixes
674674

675-
## Fix use of `new` in `delegate_components!` when keys array are used
675+
## Fix use of `new` in `delegate_components!` when keys array is used
676676

677-
We have fixed a bug in `delegate_components!`, when value expressions such as `UseDelegate<new InnerComponents { ... }>` are used together with multiple keys in a list.
677+
A bug in `delegate_components!` has been fixed that occurred when value expressions like `UseDelegate<new InnerComponents { ... }>` were used with multiple keys in a list.
678678

679-
For example, given the following:
679+
For example:
680680

681681
```rust
682682
delegate_components! {
@@ -693,21 +693,21 @@ delegate_components! {
693693
}
694694
```
695695

696-
Previously, the inner struct `InnerComponents` would be expanded twice. With this PR, the struct `InnerComponents` would be expanded once regardless of how many keys are in the delegate entry.
696+
Previously, the inner struct `InnerComponents` would be expanded twice. With this fix, `InnerComponents` is expanded only once, regardless of the number of keys in the delegate entry.
697697

698698
# Other Updates
699699

700700
## RustLab Presentation
701701

702-
Next month in November, I will be presenting about CGP at [RustLab](https://rustlab.it/talks/how-to-stop-fighting-with-coherence-and-start-writing-context-generic-trait-impls) in Florence, with the presentation titled [How to Stop Fighting with Coherence and Start Writing Context-Generic Trait Impls](https://rustlab.it/talks/how-to-stop-fighting-with-coherence-and-start-writing-context-generic-trait-impls).
702+
Next month in November, I will be presenting about CGP at [RustLab](https://rustlab.it/talks/how-to-stop-fighting-with-coherence-and-start-writing-context-generic-trait-impls) in Florence. The presentation is titled [How to Stop Fighting with Coherence and Start Writing Context-Generic Trait Impls](https://rustlab.it/talks/how-to-stop-fighting-with-coherence-and-start-writing-context-generic-trait-impls).
703703

704-
If you are interested to attend the conference, you can use the discount code `SP20FR` for a 20% discount.
704+
If you are interested in attending, you can use the discount code `SP20FR` for a 20% discount.
705705

706706
## `cgp-serde`
707707

708-
Together with the RustLab presentation, I am working on [`cgp-serde`](https://github.com/contextgeneric/cgp-serde) to provide an extensible version of the popular `serde` crate. Here is a sneak preview of what it is going to offer.
708+
Alongside the RustLab presentation, I am working on [`cgp-serde`](https://github.com/contextgeneric/cgp-serde), which provides an extensible version of the popular `serde` crate. Here is a sneak preview of its capabilities.
709709

710-
The crate offers context-generic versions of the `Serialize` and `Deserialize` traits as follows:
710+
The crate offers context-generic versions of the `Serialize` and `Deserialize` traits:
711711

712712
```rust
713713
#[cgp_component {
@@ -731,11 +731,11 @@ pub trait CanDeserializeValue<'de, Value> {
731731
}
732732
```
733733

734-
The `cgp-serde` traits remain compatible with the original `serde` constructs. This means that we can reuse existing `serde` implementations without needing to re-implement everything to work with `cgp-serde`.
734+
The `cgp-serde` traits remain compatible with the original `serde` traits. This allows reuse of existing `serde` implementations without reimplementing them for `cgp-serde`.
735735

736-
In addition to the existing capabilities, `cgp-serde` makes it possible for us to customize how specific field types should be serialized. For example, we can customize how `Vec<u8>` or `Datetime` should be serialized, without being restricted by the coherence restrictions of the trait system.
736+
In addition, `cgp-serde` allows customizing how specific field types are serialized. For example, `Vec<u8>` or `Datetime` can be serialized in a custom manner without being restricted by trait coherence rules.
737737

738-
Another key feature that is unlocked by `cgp-serde` is that it unlocks the use of the ideas behind [context and capabilities](https://tmandry.gitlab.io/blog/posts/2021-12-21-context-capabilities/), and makes them usable with `serde`. For example, here is a CGP provider implementation that allocates memory for a value type using an arena allocator provided by the context:
738+
Another key feature of `cgp-serde` is that it enables the use of [context and capabilities](https://tmandry.gitlab.io/blog/posts/2021-12-21-context-capabilities/) patterns with `serde`. For instance, here is a provider implementation that allocates memory for a value type using an arena allocator provided by the context:
739739

740740
```rust
741741
#[cgp_new_provider]
@@ -756,9 +756,9 @@ where
756756
}
757757
```
758758

759-
With that, we can for example implement a deserialization context that provides an arena allocator, and use that to deserialize into a `&'a Payload` value.
759+
This allows the implementation of a deserialization context that provides an arena allocator and uses it to deserialize into a `&'a Value`.
760760

761-
Following shows an example deserializer context, together with some custom deserializer providers:
761+
An example of a deserializer context with custom deserializer providers is shown below:
762762

763763
```rust
764764
#[derive(CgpData)]
@@ -789,16 +789,15 @@ delegate_components! {
789789
}
790790
```
791791

792-
As we can see in the above example, in the wiring for `ValueDeserializerComponent`, we use `UseDelegate` to create a table lookup for the deserialization implementation for different value types. We first use `UseSerde` to implement deserialization using the original `Deserialize` trait from `serde`. We then use `DeserializeHex` to deserialize a hex string into `Vec<u8>` bytes.
793792

794-
Next, we use `DeserializeRecordFields` to deserialize each field in `Payload` by using their respective value deserializers. This is made possible with the use of `#[derive(CgpData)]` on the `Payload` struct. It also demonstrates that we don't even need to derive any serialization trait on `Payload` in order to make it serializable using `cgp-serde`.
793+
As we can see in the above example, within the wiring for `ValueDeserializerComponent`, we use `UseDelegate` to create a table lookup for deserialization implementations corresponding to different value types. First, `UseSerde` is used to implement deserialization via the original `Deserialize` trait from `serde`. After that, `DeserializeHex` handles the conversion of a hex string into a `Vec<u8>`.
795794

796-
Finally, we use `DeserializeAndAllocate` to deserialize a `&'a Payload` value by allocating the payload into the arena allocator provided by the context.
795+
Next, `DeserializeRecordFields` is applied to deserialize each field in the `Payload` struct using their respective value deserializers. This functionality is enabled by the `#[derive(CgpData)]` attribute on `Payload`. The example also illustrates that it is not necessary to derive any serialization traits on `Payload` to make it work with `cgp-serde`.
797796

798-
There are many more details that I skipped here, that will need to be explained further along with the official release of `cgp-serde`. The crate is almost usable already, and the final work is on preparing for the remaining documentation.
797+
Finally, `DeserializeAndAllocate` is used to deserialize a `&'a Payload` value by allocating the payload in the arena allocator provided by the context.
799798

800-
I will also be demonstrating the use of `cgp-serde` at [RustLab](https://rustlab.it/talks/how-to-stop-fighting-with-coherence-and-start-writing-context-generic-trait-impls). So if you are interested to find out more, do come and join me at the conference!
799+
There are many additional details that will be explained further with the official release of `cgp-serde`. The crate is nearly ready, with the remaining work focused on documentation. I will also demonstrate `cgp-serde` at [RustLab](https://rustlab.it/talks/how-to-stop-fighting-with-coherence-and-start-writing-context-generic-trait-impls). If you are interested in learning more, join the conference to see it in action.
801800

802801
# Acknowledgement
803802

804-
Thank you Abhishek Tripathi and Dzmitry Lahoda for [sponsoring](https://github.com/sponsors/soareschen) the development of CGP!
803+
Thank you April Gonçalves, Abhishek Tripathi and Dzmitry Lahoda for [sponsoring](https://github.com/sponsors/soareschen) the development of CGP!

0 commit comments

Comments
 (0)