1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

factor::Factors::add: Split up to work without NLL

Co-authored-by: Roy Ivy III <rivy.dev@gmail.com>
This commit is contained in:
Nicolas Braud-Santoni 2020-05-24 19:14:37 +02:00 committed by GitHub
parent 36a2948959
commit 4c3682aec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,8 @@ impl Factors {
fn add(&mut self, prime: u64, exp: u8) { fn add(&mut self, prime: u64, exp: u8) {
assert!(exp > 0); assert!(exp > 0);
self.f.insert(prime, exp + self.f.get(&prime).unwrap_or(&0)); let n = *self.f.get(&prime).unwrap_or(&0);
self.f.insert(prime, exp + n);
} }
fn push(&mut self, prime: u64) { fn push(&mut self, prime: u64) {