-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Reform rational #6471
Reform rational #6471
Conversation
My reasoning for |
This allows creating `Ratio<T>` which `T` is non-implicitly copyable types such as `BigInt`.
Cool! (Nice clean-up.) |
Actually thinking about it a bit more, it would be better to use the gcd implementation on the Integer trait than to have the one in the rational.rs. (Since the performance of the type-specific one will presumably be much better.) So I think that the |
@huonw It is correct in the performance sense, but it is strange in the naming convention sense (polynomials is For now, in this pull request, using |
I agree about the naming, but names are always hard, and I added a note to #4819. (I don't have magical r+ powers, by the way.) |
Oh, I didn't know you don't have the power, sorry. |
`std::ratio` module contains `BigRational` type, but the type is not usable by following reasons. * `Ratio::new` requires `T: Copy + Num + Ord`, but `BigInt` is not implicitly copyable, because it contains unique vector. * `BigInt` is not implements `Num` So, I rewrite `Ratio` as follows. * `Ratio` requires `T: Clone + Integer + Ord`. * `Copy` -> `Clone`: to be able to use `BigRational` * `Num` -> `Integer`: It is incorrect that a rational number constructed by two non-integer numbers. * `BigInt` implements `Num` and `Orderable` which are required by `Integer` bound
Fix blessing of new reference files Adding of new reference files wasn't handled correctly. It was trying to read a file that didn't exist yet. Instead of unwrapping, we now treat a missing reference file as empty (`Vec::new`). This makes the following conditional work. We then also have to re-read the reference file after it was being copied. This second read is technically the same as in the old shell script, but wasn't really obvious there. The shell script did a `-s` test which reads the file as well. changelog: internal: Fix `cargo dev bless` when new reference files are added
std::ratio
module containsBigRational
type, but the type is not usable by following reasons.Ratio::new
requiresT: Copy + Num + Ord
, butBigInt
is not implicitly copyable, because it contains unique vector.BigInt
is not implementsNum
So, I rewrite
Ratio
as follows.Ratio
requiresT: Clone + Integer + Ord
.Copy
->Clone
: to be able to useBigRational
Num
->Integer
: It is incorrect that a rational number constructed by two non-integer numbers.BigInt
implementsNum
andOrderable
which are required byInteger
bound