Implement CheckedNeg for Ratio - #159
Open
RanaPriyansh wants to merge 1 commit into
Open
RanaPriyansh wants to merge 1 commit into
RanaPriyansh wants to merge 1 commit into
Conversation
RanaPriyansh
force-pushed
the
feat/checked-neg-137
branch
from
September 24, 2026 09:44
e366f57 to
74a288a
Compare
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.
Add
CheckedNegforRatio<T>whenTsupports checked negation. This provides a checked alternative for cases such as negatingRatio::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, andci/test_full.shpass 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
CheckedNegtrait; currentBigIntdoes not implement it.Fixes #137.