Refactor workflow macro and enhance composite arm handling#3
Merged
Conversation
- Introduced a new crate `floxide-macros-support` for shared macro functionality. - Updated `Cargo.toml` and `Cargo.lock` to include `floxide-macros-support` as a dependency. - Refactored `floxide-macros` to utilize types from `floxide-macros-support`. - Added tests for composite arms in `floxide-macros` to ensure correct parsing and functionality. - Modified example workflow to return meaningful output based on input conditions.
- Added new dependencies including `trybuild`, `glob`, `serde_spanned`, `target-triple`, `termcolor`, `toml`, `toml_datetime`, `toml_edit`, `toml_write`, and `winnow` in `Cargo.lock`. - Updated `Cargo.toml` for `floxide-macros` to include `trybuild` as a development dependency. - Enhanced the `workflow` macro in `floxide-macros` to include type assertions for direct edges, improving type safety. - Fixed tests in `composite_arms.rs` to correctly assert wildcard behavior in edge definitions. - Minor refactor in `floxide-macros-support` to clarify wildcard handling in variant bindings.
- Added `floxide-macros-support` as a dependency in `Cargo.toml` for floxide-macros. - Refined the `workflow` macro to improve pattern matching by removing unnecessary variable bindings in the branch actions. - Ensured consistency in the handling of `BatchAction::Small` by removing the unused variable in the macro definition.
- Simplified the `workflow` macro in `floxide-macros` by consolidating the handling of composite arms and improving the pattern matching logic. - Updated the handling of `BatchAction::Small` to correctly accept a parameter, ensuring consistency in action definitions. - Made adjustments in `floxide-macros-support` to clarify the parsing of composite edges and added debug logs for better traceability of parsed arms.
- Improved the `workflow` macro in `floxide-macros` to generate compile-time trait-based assertions for type compatibility between connected nodes, enhancing error messages with node names. - Introduced a new test file `type_mismatch.rs` to verify that type mismatches produce appropriate compile-time errors, ensuring better type safety in workflows. - Updated existing tests for consistency and clarity in edge definitions.
- Changed the Rust code block in the `retry.rs` documentation to ignore compilation errors for better clarity. - Updated the example in `lib.rs` to include `SharedState` and `Node`, reflecting changes in the context struct and output type for improved functionality and consistency in the workflow examples.
- Simplified the `workflow` macro in `floxide-macros` by consolidating imports and streamlining identifier generation for traits and functions. - Updated test files to ensure proper formatting and consistency, including adding newlines at the end of files for better compatibility with tools. - Enhanced the parsing logic in `floxide-macros-support` to improve clarity and maintainability of edge definitions.
- Simplified the handling of direct edges in the `workflow` macro by replacing the match statement with an if-let construct for improved readability. - Removed unnecessary else branches to enhance clarity in the pattern matching logic. - Maintained the generation of compile-time trait-based assertions for type compatibility between connected nodes, ensuring consistent error messaging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a significant refactoring of the
workflowmacro infloxide-macrosand related components. The primary goals of these changes are to improve code clarity, enhance type safety, and streamline the handling of edge definitions, particularly for composite arms.Key improvements include:
workflowmacro has been simplified by:floxide-macros-supportCrate: A new crate,floxide-macros-support, has been created to house shared data structures and parsing logic for the macros, promoting better code organization and reusability.retry.rsandlib.rshave been updated to reflect the latest API changes and best practices, including the use ofSharedState. The branching example now returns meaningful output.Changes by Crate
floxide-macrosworkflow.rs:WorkflowDef,EdgeKind, andCompositeArmtofloxide-macros-support.Cargo.toml:floxide-macros-supportas a dependency.trybuildas a dev-dependency for compile-fail tests.tests/compile_fail_tests.rswithtype_mismatch.rsUI test.tests/composite_arms.rsto test parsing of various composite arm syntaxes.tests/workflow.rsto reflect new syntax and remove unnecessary bindings in composite arms.floxide-macros-support(New Crate)WorkflowDef,EdgeKind,CompositeArm, and the associated parsing logic, extracted fromfloxide-macros/src/workflow.rs.examples/branching_example.rsStringto provide more meaningful return values._) where bindings are not needed.src/lib.rsSharedStatefor the context and reflect changes in node output types.Detailed Commit History
floxide-macros-support.retry.rsdoc example.lib.rsexample withSharedStateandNode.type_mismatch.rscompile-fail test.BatchAction::Smallparameter handling.floxide-macros-supportdependency.Cargo.lock.trybuilddev-dependency.composite_arms.rstests.floxide-macros-supportcrate.floxide-macros.This refactoring aims to make the workflow definition more robust, easier to understand, and less error-prone.