diff --git a/src/bank.rs b/src/bank.rs index 13dc1a077..8bd1f844f 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -215,8 +215,8 @@ impl Bank { .read() .expect("timestamp creation in apply_credits"))); - if let Some(ref payment) = plan.final_payment() { - self.apply_payment(payment); + if let Some(payment) = plan.final_payment() { + self.apply_payment(&payment); } else { let mut pending = self.pending .write() @@ -329,8 +329,8 @@ impl Bank { plan.apply_witness(&Witness::Timestamp(*self.last_time .read() .expect("'last_time' read lock when creating timestamp"))); - if let Some(ref payment) = plan.final_payment() { - self.apply_payment(payment); + if let Some(payment) = plan.final_payment() { + self.apply_payment(&payment); completed.push(key.clone()); } } diff --git a/src/banking_stage.rs b/src/banking_stage.rs index 62f480b29..b80fd0541 100644 --- a/src/banking_stage.rs +++ b/src/banking_stage.rs @@ -293,7 +293,7 @@ mod bench { &packet_recycler, ).unwrap(); let signal = signal_receiver.recv().unwrap(); - if let Signal::Events(ref transactions) = signal { + if let Signal::Events(transactions) = signal { assert_eq!(transactions.len(), tx); } else { assert!(false); diff --git a/src/budget.rs b/src/budget.rs index be970b088..71336b569 100644 --- a/src/budget.rs +++ b/src/budget.rs @@ -18,8 +18,8 @@ impl Condition { /// Return true if the given Witness satisfies this Condition. pub fn is_satisfied(&self, witness: &Witness) -> bool { match (self, witness) { - (&Condition::Signature(ref pubkey), &Witness::Signature(ref from)) => pubkey == from, - (&Condition::Timestamp(ref dt), &Witness::Timestamp(ref last_time)) => dt <= last_time, + (Condition::Signature(pubkey), Witness::Signature(from)) => pubkey == from, + (Condition::Timestamp(dt), Witness::Timestamp(last_time)) => dt <= last_time, _ => false, } } @@ -67,31 +67,27 @@ impl Budget { impl PaymentPlan for Budget { /// Return Payment if the budget requires no additional Witnesses. fn final_payment(&self) -> Option { - match *self { - Budget::Pay(ref payment) => Some(payment.clone()), + match self { + Budget::Pay(payment) => Some(payment.clone()), _ => None, } } /// Return true if the budget spends exactly `spendable_tokens`. fn verify(&self, spendable_tokens: i64) -> bool { - match *self { - Budget::Pay(ref payment) | Budget::After(_, ref payment) => { - payment.tokens == spendable_tokens - } - Budget::Race(ref a, ref b) => { - a.1.tokens == spendable_tokens && b.1.tokens == spendable_tokens - } + match self { + Budget::Pay(payment) | Budget::After(_, payment) => payment.tokens == spendable_tokens, + Budget::Race(a, b) => a.1.tokens == spendable_tokens && b.1.tokens == spendable_tokens, } } /// Apply a witness to the budget to see if the budget can be reduced. /// If so, modify the budget in-place. fn apply_witness(&mut self, witness: &Witness) { - let new_payment = match *self { - Budget::After(ref cond, ref payment) if cond.is_satisfied(witness) => Some(payment), - Budget::Race((ref cond, ref payment), _) if cond.is_satisfied(witness) => Some(payment), - Budget::Race(_, (ref cond, ref payment)) if cond.is_satisfied(witness) => Some(payment), + let new_payment = match self { + Budget::After(cond, payment) if cond.is_satisfied(witness) => Some(payment), + Budget::Race((cond, payment), _) if cond.is_satisfied(witness) => Some(payment), + Budget::Race(_, (cond, payment)) if cond.is_satisfied(witness) => Some(payment), _ => None, }.cloned(); diff --git a/src/crdt.rs b/src/crdt.rs index e2c3506d8..56c950dd5 100644 --- a/src/crdt.rs +++ b/src/crdt.rs @@ -505,7 +505,7 @@ impl Crdt { blob_recycler: &BlobRecycler, ) -> Option { let pos = (ix as usize) % window.read().unwrap().len(); - if let &Some(ref blob) = &window.read().unwrap()[pos] { + if let Some(blob) = &window.read().unwrap()[pos] { let rblob = blob.read().unwrap(); let blob_ix = rblob.get_index().expect("run_window_request get_index"); if blob_ix == ix { diff --git a/src/streamer.rs b/src/streamer.rs index 5019651f2..e607ed177 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -270,7 +270,7 @@ fn recv_window( let mut window = locked_window.write().unwrap(); if window[w].is_none() { window[w] = Some(b_); - } else if let &Some(ref cblob) = &window[w] { + } else if let Some(cblob) = &window[w] { if cblob.read().unwrap().get_index().unwrap() != pix as u64 { warn!("overrun blob at index {:}", w); } else { diff --git a/src/thin_client.rs b/src/thin_client.rs index 3b40ca047..d783d4b7b 100644 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -105,7 +105,7 @@ impl ThinClient { while !done { let resp = self.recv_response()?; trace!("recv_response {:?}", resp); - if let &Response::Balance { ref key, .. } = &resp { + if let Response::Balance { key, .. } = &resp { done = key == pubkey; } self.process_response(resp); diff --git a/tests/data_replicator.rs b/tests/data_replicator.rs index 644f3d8c4..e6f37f556 100644 --- a/tests/data_replicator.rs +++ b/tests/data_replicator.rs @@ -45,7 +45,7 @@ where for i in 0..(num * 32) { done = false; trace!("round {}", i); - for &(ref c, _, _) in listen.iter() { + for (c, _, _) in &listen { if num == c.read().unwrap().convergence() as usize { done = true; break;