Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiimk committed Jul 29, 2024
1 parent 17adbf8 commit db78d9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- It's now possible to associate custom static metadata with builders:
```rust
#[component]
#[interface(dyn EventHandler)]
#[meta(EventHandlerDesc { event_type: "A"})]
#[meta(EventHandlerDesc { event_type: "B"})]
struct EventHandlerAB;
```
- New `BuilderExt` trait was added to provide convenient access to metadata and interfaces
- New `Catalog::builders_for_with_meta()` allows to filter builders by metadata with a custom predicate
### Changed
- `Builder::interfaces` method was changed to iteration via callback to avoid allocating a `Vec`

## [0.8.1] - 2024-05-27
### Fixed
- Fixed pedantic linter warnings
Expand Down
8 changes: 4 additions & 4 deletions dill-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ fn implement_builder(
let meta_provide: Vec<_> = meta
.iter()
.enumerate()
.map(|(i, e)| implmenent_meta_provide(i, e))
.map(|(i, e)| implement_meta_provide(i, e))
.collect();
let meta_vars: Vec<_> = meta
.iter()
.enumerate()
.map(|(i, e)| implmenent_meta_var(i, e))
.map(|(i, e)| implement_meta_var(i, e))
.collect();

let mut arg_override_fn_field = Vec::new();
Expand Down Expand Up @@ -423,15 +423,15 @@ fn implement_arg(

/////////////////////////////////////////////////////////////////////////////////////////

fn implmenent_meta_var(index: usize, expr: &syn::ExprStruct) -> proc_macro2::TokenStream {
fn implement_meta_var(index: usize, expr: &syn::ExprStruct) -> proc_macro2::TokenStream {
let ident = format_ident!("_meta_{index}");
let typ = &expr.path;
quote! {
const #ident: #typ = #expr;
}
}

fn implmenent_meta_provide(index: usize, _expr: &syn::ExprStruct) -> proc_macro2::TokenStream {
fn implement_meta_provide(index: usize, _expr: &syn::ExprStruct) -> proc_macro2::TokenStream {
let ident = format_ident!("_meta_{index}");
quote! {
if !clb(&Self::#ident) { return }
Expand Down

0 comments on commit db78d9a

Please sign in to comment.