Skip to content

Re-export chainrules-core and add Neg bound to ScalarAd#1

Merged
shinaoka merged 1 commit intomainfrom
reexport-core-and-neg-bound
Mar 19, 2026
Merged

Re-export chainrules-core and add Neg bound to ScalarAd#1
shinaoka merged 1 commit intomainfrom
reexport-core-and-neg-bound

Conversation

@shinaoka
Copy link
Copy Markdown
Member

Summary

  • Re-export chainrules-core public types from chainrules: downstream crates can depend on chainrules alone to access Differentiable, ReverseRule, ForwardRule, AutodiffError, NodeId, etc.
  • Add Neg<Output = Self> bound to ScalarAd: enables idiomatic -x syntax, removing neg_one() helper and S::from_i32(-1) * ... workarounds in sub_rrule, div_frule/div_rrule, cos_frule/cos_rrule, acos_frule/acos_rrule.

Test plan

  • cargo nextest run --release --workspace — all 60 tests pass
  • cargo test --doc --release --workspace — all doc tests pass
  • cargo clippy --workspace — no warnings

🤖 Generated with Claude Code

Downstream crates can now depend on `chainrules` alone to get core
traits (Differentiable, ReverseRule, ForwardRule, etc.). Adding `Neg`
to `ScalarAd` removes the `neg_one()` helper and `from_i32(-1) *`
workarounds, making negation idiomatic (`-x` instead of `-1 * x`).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shinaoka shinaoka merged commit dffde99 into main Mar 19, 2026
5 checks passed
@shinaoka shinaoka deleted the reexport-core-and-neg-bound branch March 19, 2026 22:57
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.

1 participant