Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions code/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ path = "bin/abstract_name.rs"
cgp = { version = "0.5.0" }

[patch.crates-io]
cgp = { git = "https://github.com/contextgeneric/cgp.git", branch = "v0.5.0-release" }
cgp = { git = "https://github.com/contextgeneric/cgp.git" }
17 changes: 7 additions & 10 deletions code/bin/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,25 @@ pub trait HasName {
}

// Implement `Greeter` that is generic over `Context`
#[cgp_new_provider]
impl<Context> Greeter<Context> for GreetHello
#[cgp_impl(new GreetHello)]
impl<Context> Greeter for Context
where
Context: HasName, // Inject the `name` dependency from `Context`
{
fn greet(context: &Context) {
// `self` is replaced by `context` inside providers
println!("Hello, {}!", context.name());
fn greet(&self) {
println!("Hello, {}!", self.name());
}
}

// A concrete context that uses CGP components
#[cgp_context]
#[derive(HasField)] // Deriving `HasField` automatically implements `HasName`
pub struct Person {
pub name: String,
}

// Compile-time wiring and checking of CGP components
delegate_and_check_components! {
CanUsePerson for Person;
PersonComponents {
// Compile-time wiring of CGP components
delegate_components! {
Person {
GreeterComponent: GreetHello, // Use `GreetHello` to provide `Greeter`
}
}
Expand Down
7 changes: 5 additions & 2 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ sort_by = "weight"

# Announcement

I am thrilled to announce the release of [**CGP v0.5.0**](/blog/v0-5-0-release/)! This new release includes many exciting features and improvements, including auto dispatchers with `#[cgp_auto_dispatch]`, extensible datatype improvements, monadic computation, emulation of return type notation (RTN), sneak preview of `cgp-serde`, and more.
I’m excited to announce the release of [**CGP v0.6.0**](/blog/v0-6-0-release/)!
This version introduces major ergonomic improvements that make provider and context implementations simpler and more intuitive to write.

[Read the announcement blog post](/blog/v0-5-0-release/) to find out more.
The new `#[cgp_impl]` and `#[cgp_inherit]` macros replace `#[cgp_provider]` and `#[cgp_context]`, offering cleaner syntax and greatly improving the readability of CGP code.

[Read the announcement blog post](/blog/v0-6-0-release/) to find out more.

# Overview

Expand Down
Loading