ACP: impl {Div,Rem}Assign<NonZeroX> for X
#346
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
At the moment, there are
impl {Div,Rem}<NonZeroX> for X
which use the fact that the division by a non-zero value are always infallible.Yet there seem to be no corresponding
{Div,Rem}Assign
implementations. While thelhs %= rhs
andlhs/= rhs
can be described in user code withlhs = lhs / rhs
andlhs = lhs % rhs
respectively, there seems to be no reason to not implement the corresponding traits on numeric types themselves.Motivating examples or use cases
Simply,
compiles; but
does not.
Solution sketch
The implementation (tested against
master
) adds the following intocore::num::nonzero::nonzero_integer_signedness_dependent_impls
:Diff
I've used the synthetic
nonzero_div2
feature for these and, IMO, they may be an insta-stable API.Alternatives
The text was updated successfully, but these errors were encountered: