Skip to content

Implement CheckedNeg for Ratio - #159

Open
RanaPriyansh wants to merge 1 commit into
rust-num:mainfrom
RanaPriyansh:feat/checked-neg-137
Open

RanaPriyansh wants to merge 1 commit into
rust-num:mainfrom
RanaPriyansh:feat/checked-neg-137

Conversation

@RanaPriyansh

Copy link
Copy Markdown

Add CheckedNeg for Ratio<T> when T supports checked negation. This provides a checked alternative for cases such as negating Ratio::new(i64::MIN, 3).

Check the numerator operation and preserve the denominator and raw representation. Existing API bounds and ordinary negation remain unchanged.

Tests cover signed and unsigned values, overflow, generic trait use, and raw numerator/denominator preservation. cargo fmt --all --check, default tests, and ci/test_full.sh pass with Rust 1.94.1. The script covers the repository's standard and no-default feature combinations.

Rust 1.60 and the embedded target remain upstream checks. This implementation requires the underlying CheckedNeg trait; current BigInt does not implement it.

Fixes #137.

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.

Rational<T> should implement CheckedNeg whenever T does

1 participant