Skip to content

Vic/jj change lznvqqpxrpll#18

Merged
vic merged 3 commits into
mainfrom
vic/jj-change-lznvqqpxrpll
Jul 11, 2025
Merged

Vic/jj change lznvqqpxrpll#18
vic merged 3 commits into
mainfrom
vic/jj-change-lznvqqpxrpll

Conversation

@vic

@vic vic commented Jul 11, 2025

Copy link
Copy Markdown
Member

No description provided.

vic added 3 commits July 11, 2025 00:40
…uction 🧩

- Updated macro to return impl Ability instead of Box for ability construction functions.
- Generalized method signatures to allow any Ability type, not just boxed trait objects.
- Updated integration tests to match new API and type signatures.
- Improves ergonomics and flexibility for effectful code and ability usage.

Future work:
- Extend macro to support more context shapes and derive HasPut for structs.
- Refactor Pair usage in effect APIs for full genericity.
- Added Fx::provide_has, allowing partial context provision using HasPut/Put trait, supporting both tuples and structs.
- Added tests for provide_has with struct context (i32 and String fields).
- Improves ergonomics for effectful code with custom context shapes.

Future work:
- Extend HasPut/Put derive macros for easier struct support.
- Refactor provide_left and related APIs to use HasPut for full genericity.
…ext mutation API 🧩

- Renamed Fx::provide_has to Fx::update_context for clarity and ergonomics.
- Updated all tests and usages to use update_context.
- Added and improved tests for struct-based context mutation and handler replacement.
- This change clarifies the API semantics, making context adaptation and mutation explicit and more general.

Future work:
- Extend HasPut/Put derive macros for easier struct support.
- Refactor related APIs for full genericity and ergonomic context adaptation.
Copilot AI review requested due to automatic review settings July 11, 2025 08:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how abilities are returned by the macro, updates tests to match the new API, and adds a new update_context helper on Fx with accompanying tests.

  • abilities_macro now returns impl Ability instead of Box<dyn Ability> and uses a generic A parameter in request methods
  • Integration tests in abilities_macro_test.rs are updated to wrap returned abilities in Box::new and fix generic arguments
  • Introduces update_context in provide.rs and adds tests in provide_test.rs to verify context updates

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
crates/abilities_macro/src/lib.rs Changed ability constructors to return impl Ability and updated request method generics
crates/integration/tests/abilities_macro_test.rs Wrapped ability closures in Box::new and added missing generic parameter
crates/fx/src/core/provide.rs Added public update_context method on Fx
crates/fx/src/core/tests/provide_test.rs Added tests for update_context and combined imports
Comments suppressed due to low confidence (3)

crates/abilities_macro/src/lib.rs:30

  • Since F is required to be Clone in the where clause, consider adding + Clone to the impl Ability return type (e.g., -> impl Ability<'f, #input_ty, #ctx_ty, #ret_ty> + Clone + 'f) so callers retain the Clone bound on the ability.
                            pub fn #ability_fn_ident<'f, F>(f: F) -> impl Ability<'f, #input_ty, #ctx_ty, #ret_ty> + 'f

crates/fx/src/core/provide.rs:19

  • Public API methods should be documented; please add a doc comment explaining how update_context transforms the context and any cloning behavior required by Put<T>.
    pub fn update_context<T>(self, t: T) -> Fx<'a, S, V>

crates/abilities_macro/src/lib.rs:34

  • [nitpick] The generic parameter order < 'f, P, A> may be non-intuitive; consider reordering to < 'f, A, P> or adding a comment, so the ability type A appears alongside its bound before the pair type P.
                            pub fn #method_ident<'f, P, A>(arg: #input_ty) -> Fx<'f, P, #ret_ty>

@vic vic merged commit 80f311b into main Jul 11, 2025
2 checks passed
@vic vic deleted the vic/jj-change-lznvqqpxrpll branch July 15, 2025 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants