refactor: split MAAValue into MAAValue and ResolvedMAAValue#485
refactor: split MAAValue into MAAValue and ResolvedMAAValue#485
MAAValue into MAAValue and ResolvedMAAValue#485Conversation
There was a problem hiding this comment.
Sorry @wangl-cc, your pull request is larger than the review limit of 150000 diff characters
|
@copilot review |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #485 +/- ##
===========================================
- Coverage 70.48% 17.14% -53.35%
===========================================
Files 61 2 -59
Lines 5825 175 -5650
Branches 5825 175 -5650
===========================================
- Hits 4106 30 -4076
+ Misses 1408 144 -1264
+ Partials 311 1 -310 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request refactors the maa-value crate to introduce a type-safe distinction between unresolved configuration templates and fully resolved values. The refactoring improves API clarity by splitting MAAValue into two distinct types and reorganizes the codebase into a more modular structure.
Changes:
- Split
MAAValueintoMAAValue(unresolved) andResolvedMAAValue(resolved) types to enforce type safety - Rename
init()method toresolve()to better reflect the transformation from unresolved to resolved state - Modularize codebase by extracting functionality into dedicated modules (
array,convert,map,value,error) and introduce traits (MapOps,ArrayOps,AsPrimitive,TryAs) for improved ergonomics - Add
maa_value::preludemodule for convenient imports - Update all dependent crates (
maa-cli,maa-value-macro) to adapt to the new API
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/maa-value/src/value.rs | Defines MAAValue and ResolvedMAAValue enums with resolve() method and conversion implementations |
| crates/maa-value/src/map.rs | Introduces MapOps trait with map-like operations (get, insert, merge, join) for both value types |
| crates/maa-value/src/convert.rs | Defines AsPrimitive and TryAs traits with conversion macros for primitive types |
| crates/maa-value/src/array.rs | Introduces ArrayOps trait for array-like operations |
| crates/maa-value/src/primitive.rs | Updates MAAPrimitive type with simplified implementation using conversion traits |
| crates/maa-value/src/lib.rs | Refactors to export modules and adds prelude with common imports |
| crates/maa-value/src/input.rs | Updates import paths to use new module structure |
| crates/maa-value/src/userinput/*.rs | Updates import paths for error module |
| crates/maa-value-macro/src/*.rs | Updates codegen to use fully qualified paths for new module structure |
| crates/maa-value-macro/tests/*.rs | Updates all tests to use resolve() instead of init() and import from prelude |
| crates/maa-cli/src/**/*.rs | Updates to use ResolvedMAAValue type and call resolve() on unresolved values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…AValue` Refactors the `maa-value` crate to distinguish between configuration templates (which may contain user inputs and conditional logic) and fully resolved values. Key changes: - Split `MAAValue` into `MAAValue` (unresolved) and `ResolvedMAAValue` (resolved) to enforce type safety. - Rename `init()` method to `resolve()` to better reflect the transformation process. - Modularize `maa-value` source code by extracting logic into `array`, `convert`, `map`, `value`, and `error` modules. - Introduce `MapOps`, `ArrayOps`, `AsPrimitive`, and `TryAs` traits to standardize operations and improve ergonomics. - Add `maa_value::prelude` for convenient imports. - Update `maa-cli` and `maa-value-macro` to adapt to the API changes and new type definitions.
02f6f8d to
3e4febe
Compare
Refactors the
maa-valuecrate to distinguish between configuration templates (which may contain user inputs and conditional logic) and fully resolved values.Key changes:
MAAValueintoMAAValue(unresolved) andResolvedMAAValue(resolved) to enforce type safety.init()method toresolve()to better reflect the transformation process.maa-valuesource code by extracting logic intoarray,convert,map,value, anderrormodules.MapOps,ArrayOps,AsPrimitive, andTryAstraits to standardize operations and improve ergonomics.maa_value::preludefor convenient imports.maa-cliandmaa-value-macroto adapt to the API changes and new type definitions.