Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Uint::iszero method #297

Merged
merged 9 commits into from
Sep 7, 2023
Merged

Add Uint::iszero method #297

merged 9 commits into from
Sep 7, 2023

Conversation

tonyke-bot
Copy link
Contributor

This change is to add the Uint::iszero() -> bool method.

Motivation

Current workaround is to use uint_variable.eq(Uint::ZERO) to check if a Uint variable is zero and is not elegant and straightforward enough.

Solution

Add Uint::iszero() -> bool

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.23% ⚠️

Comparison is base (76f9aa7) 80.51% compared to head (66a1a88) 80.28%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #297      +/-   ##
==========================================
- Coverage   80.51%   80.28%   -0.23%     
==========================================
  Files          54       54              
  Lines        5983     5996      +13     
==========================================
- Hits         4817     4814       -3     
- Misses       1166     1182      +16     
Files Changed Coverage Δ
src/cmp.rs 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@recmo recmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I was on the fence on whether to add it or not.
The Rust build in uints don't have it for example, but x == 0 is slightly easier than x == Uint::ZERO. Doing x.is_zero() is a bit more concise.

An open issue is to add support for num-traits ( #226 ) which also includes is_zero().

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@tonyke-bot
Copy link
Contributor Author

Thanks for the prompt review! Just update the PR per your comments.

Would be great to add support for num-traits but let's make it a separated PR if we finally decide to implement it.

recmo
recmo previously requested changes Aug 27, 2023
Copy link
Owner

@recmo recmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. I started working on num-traits #298 .

src/cmp.rs Outdated Show resolved Hide resolved
@tonyke-bot
Copy link
Contributor Author

@recmo

MSRV is set to 1.65 but I'm currently failing CI for 1.65 build for this reason:

error: package `clap_builder v4.4.2` cannot be built because it requires rustc 1.70.0 or newer, while the currently active rustc version is 1.65.0
Either upgrade to rustc 1.70.0 or newer, or use
cargo update -p clap_builder@4.4.2 --precise ver
where `ver` is the latest version of `clap_builder` supporting rustc 1.65.0
Error: Process completed with exit code 101.

Can you adjust the MSRV or fix the dependencies so that I can merge this PR?

@prestwich
Copy link
Collaborator

it looks like criterion updated deps in a way that broke our MSRV. We can likely go back and pin the dep version we need

cc @DaniPopes to check my beliefs

@DaniPopes
Copy link
Contributor

See alloy-rs/core#246

@tonyke-bot
Copy link
Contributor Author

Thanks! Borrow @DaniPopes 's idea to fix the 1.65 test with another PR #306

@tonyke-bot
Copy link
Contributor Author

Unable to merge the PR yet. All request changes should be resolved but GitHub still asking for requested changes to be addressed. Or do @recmo need to approve explicitly?

@prestwich
Copy link
Collaborator

Unable to merge the PR yet. All request changes should be resolved but GitHub still asking for requested changes to be addressed. Or do @recmo need to approve explicitly?

I went ahead and dismissed his review. This is de minimis and his comments were addressed so I'm pretty confident he'll forgive me for merging

@prestwich prestwich merged commit da9f1a4 into recmo:main Sep 7, 2023
12 of 13 checks passed
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.

4 participants