Skip to main content

cgp v0.6.1

Version 0.6.1 of cgp, the library for Context-Generic Programming (CGP) that enables pluggable trait implementations in Rust, lets a provider leave out its context type, checks a provider on its own, and lets a getter trait declare an associated type. This page lists every change a user can see and the steps that take a project there from v0.6.0.

Released on 2026-02-01.

Summary​

#[cgp_impl] accepts an impl header without the context type, so a provider reads as impl Greeter where Self: HasName. check_components! gains #[check_providers(...)], which asserts that each listed provider works for a context, and #[cgp_auto_getter] and #[cgp_getter] accept a getter trait that declares an associated type. The release removes and renames nothing.

Compatibility​

  • Minimum Rust version: 1.89, unchanged from v0.6.0.
  • Released together: the workspace's 23 crates published on crates.io, all at 0.6.1.

Upgrading​

A project moving from v0.6.0 changes the version to cgp = "0.6.1", and nothing else is needed. The release removes and renames no item, and the explicit impl<Context> Greeter for Context header, a plain check_components! table, and a getter trait without an associated type all compile as they did at v0.6.0.

New features​

Providers​

  • #[cgp_impl] accepts an impl header without the context type. #[cgp_impl(new GreetHello)] impl Greeter where Self: HasName { … } means the same as impl<Context> Greeter for Context where Context: HasName { … }. The header names the consumer trait where the explicit form names the context, and the macro adds the context parameter itself, so Self stands for that context (#189). A v0.6.0 #[cgp_impl] rejected the header with expect impl trait to contain path. The explicit form keeps working. See #[cgp_impl].

Wiring and checking​

  • #[check_providers(...)] checks each listed provider. check_components! asserts by default that the context can use each component. With #[check_providers(RectangleArea, ScaledArea<RectangleArea>)] before the check trait's name, it asserts instead that each listed provider is a provider for the component and the context, meaning that it implements IsProviderFor (#190). The check does not read the context's wiring, so it passes for a provider that the context does not use. A missing dependency is reported against the provider that needs it, which separates the failing layer of a composed provider from the layers that work. See checking each provider.
  • One check_components! invocation may hold several tables, so a plain check and a provider check sit in the same invocation (#190). A v0.6.0 invocation with a second table failed with unexpected token. See check_components!.

Getter traits​

  • A getter trait may declare an associated type. #[cgp_auto_getter] and #[cgp_getter] accept type Name: Display; beside one getter method that returns &Self::Name, and the context's field decides the type, which must satisfy the declared bound (#191). A v0.6.0 getter trait with an associated type failed with getter trait can only contain getter methods, so the type needed a separate #[cgp_type] trait. The trait takes one associated type, without generic parameters, and exactly one getter method. The method's return type must read that type. See #[cgp_auto_getter] and #[cgp_getter].

An AI agent wrote this page from the release's source changes and the CGP knowledge base. Its content was verified against the library's source at the release's tag. See How AI is used in this project.