-
Notifications
You must be signed in to change notification settings - Fork 19
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
ACP: isqrt
for NonZero<uN>
#391
Comments
My motivation suggesting With |
(Disclaimer: I'm not libs-api) This seems entirely reasonable to me, under the same "it's helpful compared to |
For the future, the following operations could have the same function signature
|
We discussed this during today's libs-api meeting and adding isqrt was accepted. |
Proposal
Problem statement
Integer primitives now have an integer square root method
isqrt
. Positive integers always have a positive square root, and it would be natural to directly express this throughNonZero
.Motivating examples or use cases
x.pow(2).isqrt()
givesx
forx: uN
, and we can extend that toNonZero<uN>
.Solution sketch
Alternatives
NonZero
constructors manually when necessary. This is either unsafe or requires.unwrap()
, which is not ideal.Links and related work
Motivation for primitive
isqrt
: rust-lang/rust#89273Tracking issue for
isqrt
: rust-lang/rust#116226Suggestion for this function: rust-lang/rust#116226 (comment)
Implementation: rust-lang/rust#126199
What happens now?
This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Possible responses
The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: