From bdaebf33c40233e537ef1584d5639679904e7bf5 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 14 Jan 2023 18:51:13 +0100 Subject: [PATCH] style: do not dereference self to perform pattern-matching Dereferencing `self` as `*self` in order to perform patten-matching using `ref` is unnecessary and will be done automatically by the compiler (match ergonomics, introduced in Rust 1.26). --- lib/src/backend.rs | 12 ++++++------ lib/src/content_hash.rs | 4 ++-- lib/src/op_store.rs | 9 +++------ lib/src/simple_op_store_model.rs | 6 +++--- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/src/backend.rs b/lib/src/backend.rs index eb5aeb79ff..bb55114594 100644 --- a/lib/src/backend.rs +++ b/lib/src/backend.rs @@ -230,25 +230,25 @@ pub enum TreeValue { impl ContentHash for TreeValue { fn hash(&self, state: &mut impl digest::Update) { use TreeValue::*; - match *self { - File { ref id, executable } => { + match self { + File { id, executable } => { state.update(&0u32.to_le_bytes()); id.hash(state); executable.hash(state); } - Symlink(ref id) => { + Symlink(id) => { state.update(&1u32.to_le_bytes()); id.hash(state); } - Tree(ref id) => { + Tree(id) => { state.update(&2u32.to_le_bytes()); id.hash(state); } - GitSubmodule(ref id) => { + GitSubmodule(id) => { state.update(&3u32.to_le_bytes()); id.hash(state); } - Conflict(ref id) => { + Conflict(id) => { state.update(&4u32.to_le_bytes()); id.hash(state); } diff --git a/lib/src/content_hash.rs b/lib/src/content_hash.rs index 619b0c8236..ff1b30b67e 100644 --- a/lib/src/content_hash.rs +++ b/lib/src/content_hash.rs @@ -71,9 +71,9 @@ impl ContentHash for String { impl ContentHash for Option { fn hash(&self, state: &mut impl digest::Update) { - match *self { + match self { None => state.update(&[0]), - Some(ref x) => { + Some(x) => { state.update(&[1]); x.hash(state) } diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index 94a4ec215f..ad89b668cc 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -125,15 +125,12 @@ pub enum RefTarget { impl ContentHash for RefTarget { fn hash(&self, state: &mut impl digest::Update) { use RefTarget::*; - match *self { - Normal(ref id) => { + match self { + Normal(id) => { state.update(&0u32.to_le_bytes()); id.hash(state); } - Conflict { - ref removes, - ref adds, - } => { + Conflict { removes, adds } => { state.update(&1u32.to_le_bytes()); removes.hash(state); adds.hash(state); diff --git a/lib/src/simple_op_store_model.rs b/lib/src/simple_op_store_model.rs index 49bd98f149..7a8ad0b2d1 100644 --- a/lib/src/simple_op_store_model.rs +++ b/lib/src/simple_op_store_model.rs @@ -181,13 +181,13 @@ impl TSerializable for RefTarget { fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> { let struct_ident = TStructIdentifier::new("RefTarget"); o_prot.write_struct_begin(&struct_ident)?; - match *self { - RefTarget::CommitId(ref f) => { + match self { + RefTarget::CommitId(f) => { o_prot.write_field_begin(&TFieldIdentifier::new("commit_id", TType::String, 1))?; o_prot.write_bytes(f)?; o_prot.write_field_end()?; }, - RefTarget::Conflict(ref f) => { + RefTarget::Conflict(f) => { o_prot.write_field_begin(&TFieldIdentifier::new("conflict", TType::Struct, 2))?; f.write_to_out_protocol(o_prot)?; o_prot.write_field_end()?;