feat: add WrappingArithmetic trait, include in LinkReference bounds, re-export num-traits#147
feat: add WrappingArithmetic trait, include in LinkReference bounds, re-export num-traits#147
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #146
…unds Add a composite WrappingArithmetic trait that bundles all six wrapping arithmetic traits from num-traits (WrappingAdd, WrappingSub, WrappingMul, WrappingNeg, WrappingShl, WrappingShr). Include it as a supertrait of LinkReference so downstream crates can use wrapping arithmetic with just T: LinkReference without needing explicit + WrappingAdd bounds. Closes #146 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Compile raw data from related issues (data-rs#16, data-rs#17, doublets-rs#47) and write analysis covering timeline, root causes, solution rationale, and downstream impact. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI manages versions automatically via changelog fragments. Fix import order to satisfy rustfmt (ops::wrapping before top-level). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:Claude Opus 4.6:
Total: (93.8K + 5.8M cached) input tokens, 22.8K output tokens, $4.059736 cost Claude Haiku 4.5: Total: (78.3K + 108.8K cached) input tokens, 3.9K / 64K (6%) output tokens, $0.126198 cost 🤖 Models used:
📎 Log file uploaded as Gist (2485KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit b549b16.
|
I think as in #141 we should reexport all related num traites we inherited from num traites library and that can be useful for the users of our library, so there is no problems with synchronization of num traites library, and all data-rs, tree-rs and doublets-rs will be able to just drop the import of num traits directly. |
|
🤖 AI Work Session Started Starting automated work session at 2026-04-14T12:38:54.299Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
Downstream crates (data-rs, tree-rs, doublets-rs) can now import PrimInt, AsPrimitive, ToPrimitive, FromPrimitive, Unsigned, Signed, and all six Wrapping* traits directly from platform-num, eliminating the need for a separate num-traits dependency and avoiding version drift risk. Addresses #141 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $1.583205📊 Context and tokens usage:
Total: (42.4K + 2.2M cached) input tokens, 9.2K output tokens, $1.583205 cost 🤖 Models used:
📎 Log file uploaded as Gist (1242KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
Summary
WrappingArithmeticcomposite trait bundling all 6 wrapping arithmetic traits fromnum-traits:WrappingAdd,WrappingSub,WrappingMul,WrappingNeg,WrappingShl,WrappingShrWrappingArithmeticas a supertrait ofLinkReference, so downstream crates can useT: LinkReferencewithout needing explicit+ WrappingAddboundsnum-traitstraits used in supertraits (PrimInt,AsPrimitive,ToPrimitive,FromPrimitive,Unsigned,Signed, and all 6Wrapping*traits), so downstream crates can drop their directnum-traitsdependency entirelyMotivation
After removing
LinkTypefromplatform-data(data-rs#16, data-rs#17),WrappingAddis needed for wrapping unsigned arithmetic inHybrid(internal/external link reference encoding). Currentlydata-rsmust addnum-traitsas an explicit dependency and writeT: LinkReference + WrappingAddeverywhere. With this change,T: LinkReferenceis sufficient.The re-exports also address #141: downstream crates (data-rs, tree-rs, doublets-rs) can now import all needed num-traits directly from
platform-num, eliminating version drift risk.Design decisions
WrappingArithmeticname: The maintainer dislikedWrappingAddas a name to add directly. After researchingnum-traits, there is no existing composite wrapping trait.WrappingArithmeticbundles all 6 wrapping ops and follows the same composite pattern asNumber(which bundlesPrimInt + Default + Debug + AsPrimitive<usize> + ToPrimitive)WrappingAdd— includesWrappingSub,WrappingMul,WrappingNeg,WrappingShl,WrappingShrsince all are implemented for all unsigned integer typesLinkReference(u8,u16,u32,u64,u128,usize) already implement all 6 wrapping traitsnum-traitstraits that appear as supertraits in this crate are re-exported, following the pattern requested in Re-export num-traits traits (Unsigned, FromPrimitive) to allow dependents to remove direct num-traits dependency #141Changes
rust/src/imp.rsWrappingArithmetictrait + added asLinkReferencesupertraitrust/src/lib.rsWrappingArithmetic, re-export all num-traits, updated docs tablerust/tests/traits.rschangelog.d/docs/case-studies/issue-146/experiments/Test plan
cargo buildcompiles cleanlycargo fmt --all -- --check— no formatting issuescargo clippy --all-targets— zero warningscargo test— 112 unit tests + 7 doc tests pass (was 96 + 6)u8,u16,u32,u64,u128,usizeCloses #146
Also addresses #141
🤖 Generated with Claude Code