From e943d932b90f4d3467a4f14fc064ff2324bbce45 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 21 Feb 2018 12:42:30 -0800 Subject: [PATCH] Change `match self` to `match *self` to avoid adding `&` to all patterns in a match. https://rust-lang-nursery.github.io/rust-clippy/v0.0.186/index.html#match_ref_pats --- lib/cretonne/src/bforest/node.rs | 60 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/cretonne/src/bforest/node.rs b/lib/cretonne/src/bforest/node.rs index 53a96f9b14..3c6b8c8774 100644 --- a/lib/cretonne/src/bforest/node.rs +++ b/lib/cretonne/src/bforest/node.rs @@ -54,8 +54,8 @@ impl Clone for NodeData { impl NodeData { /// Is this a free/unused node? pub fn is_free(&self) -> bool { - match self { - &NodeData::Free { .. } => true, + match *self { + NodeData::Free { .. } => true, _ => false, } } @@ -65,10 +65,10 @@ impl NodeData { /// This is the number of outgoing edges in an inner node, or the number of key-value pairs in /// a leaf node. pub fn entries(&self) -> usize { - match self { - &NodeData::Inner { size, .. } => usize::from(size) + 1, - &NodeData::Leaf { size, .. } => usize::from(size), - &NodeData::Free { .. } => panic!("freed node"), + match *self { + NodeData::Inner { size, .. } => usize::from(size) + 1, + NodeData::Leaf { size, .. } => usize::from(size), + NodeData::Free { .. } => panic!("freed node"), } } @@ -96,8 +96,8 @@ impl NodeData { /// Unwrap an inner node into two slices (keys, trees). pub fn unwrap_inner(&self) -> (&[F::Key], &[Node]) { - match self { - &NodeData::Inner { + match *self { + NodeData::Inner { size, ref keys, ref tree, @@ -113,8 +113,8 @@ impl NodeData { /// Unwrap a leaf node into two slices (keys, values) of the same length. pub fn unwrap_leaf(&self) -> (&[F::Key], &[F::Value]) { - match self { - &NodeData::Leaf { + match *self { + NodeData::Leaf { size, ref keys, ref vals, @@ -132,8 +132,8 @@ impl NodeData { /// Unwrap a mutable leaf node into two slices (keys, values) of the same length. pub fn unwrap_leaf_mut(&mut self) -> (&mut [F::Key], &mut [F::Value]) { - match self { - &mut NodeData::Leaf { + match *self { + NodeData::Leaf { size, ref mut keys, ref mut vals, @@ -152,8 +152,8 @@ impl NodeData { /// Get the critical key for a leaf node. /// This is simply the first key. pub fn leaf_crit_key(&self) -> F::Key { - match self { - &NodeData::Leaf { size, ref keys, .. } => { + match *self { + NodeData::Leaf { size, ref keys, .. } => { debug_assert!(size > 0, "Empty leaf node"); keys.borrow()[0] } @@ -165,8 +165,8 @@ impl NodeData { /// This means that `key` is inserted at `keys[i]` and `node` is inserted at `tree[i + 1]`. /// If the node is full, this leaves the node unchanged and returns false. pub fn try_inner_insert(&mut self, index: usize, key: F::Key, node: Node) -> bool { - match self { - &mut NodeData::Inner { + match *self { + NodeData::Inner { ref mut size, ref mut keys, ref mut tree, @@ -191,8 +191,8 @@ impl NodeData { /// Try to insert `key, value` at `index` in a leaf node, but fail and return false if the node /// is full. pub fn try_leaf_insert(&mut self, index: usize, key: F::Key, value: F::Value) -> bool { - match self { - &mut NodeData::Leaf { + match *self { + NodeData::Leaf { ref mut size, ref mut keys, ref mut vals, @@ -222,8 +222,8 @@ impl NodeData { /// The `insert_index` parameter is the position where an insertion was tried and failed. The /// node will be split in half with a bias towards an even split after the insertion is retried. pub fn split(&mut self, insert_index: usize) -> SplitOff { - match self { - &mut NodeData::Inner { + match *self { + NodeData::Inner { ref mut size, ref keys, ref tree, @@ -262,7 +262,7 @@ impl NodeData { }, } } - &mut NodeData::Leaf { + NodeData::Leaf { ref mut size, ref keys, ref vals, @@ -307,8 +307,8 @@ impl NodeData { /// /// Return an indication of the node's health (i.e. below half capacity). pub fn inner_remove(&mut self, index: usize) -> Removed { - match self { - &mut NodeData::Inner { + match *self { + NodeData::Inner { ref mut size, ref mut keys, ref mut tree, @@ -332,8 +332,8 @@ impl NodeData { /// /// Return an indication of the node's health (i.e. below half capacity). pub fn leaf_remove(&mut self, index: usize) -> Removed { - match self { - &mut NodeData::Leaf { + match *self { + NodeData::Leaf { ref mut size, ref mut keys, ref mut vals, @@ -553,15 +553,15 @@ where F::Value: ValDisp, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - &NodeData::Inner { size, keys, tree } => { + match *self { + NodeData::Inner { size, keys, tree } => { write!(f, "[ {}", tree[0])?; for i in 0..usize::from(size) { write!(f, " {} {}", keys[i], tree[i + 1])?; } write!(f, " ]") } - &NodeData::Leaf { size, keys, vals } => { + NodeData::Leaf { size, keys, vals } => { let keys = keys.borrow(); let vals = vals.borrow(); write!(f, "[")?; @@ -571,8 +571,8 @@ where } write!(f, " ]") } - &NodeData::Free { next: Some(n) } => write!(f, "[ free -> {} ]", n), - &NodeData::Free { next: None } => write!(f, "[ free ]"), + NodeData::Free { next: Some(n) } => write!(f, "[ free -> {} ]", n), + NodeData::Free { next: None } => write!(f, "[ free ]"), } } }