mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-16 20:54:27 +00:00
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).
This commit is contained in:
parent
c6d9024ef3
commit
bdaebf33c4
@ -230,25 +230,25 @@ pub enum TreeValue {
|
|||||||
impl ContentHash for TreeValue {
|
impl ContentHash for TreeValue {
|
||||||
fn hash(&self, state: &mut impl digest::Update) {
|
fn hash(&self, state: &mut impl digest::Update) {
|
||||||
use TreeValue::*;
|
use TreeValue::*;
|
||||||
match *self {
|
match self {
|
||||||
File { ref id, executable } => {
|
File { id, executable } => {
|
||||||
state.update(&0u32.to_le_bytes());
|
state.update(&0u32.to_le_bytes());
|
||||||
id.hash(state);
|
id.hash(state);
|
||||||
executable.hash(state);
|
executable.hash(state);
|
||||||
}
|
}
|
||||||
Symlink(ref id) => {
|
Symlink(id) => {
|
||||||
state.update(&1u32.to_le_bytes());
|
state.update(&1u32.to_le_bytes());
|
||||||
id.hash(state);
|
id.hash(state);
|
||||||
}
|
}
|
||||||
Tree(ref id) => {
|
Tree(id) => {
|
||||||
state.update(&2u32.to_le_bytes());
|
state.update(&2u32.to_le_bytes());
|
||||||
id.hash(state);
|
id.hash(state);
|
||||||
}
|
}
|
||||||
GitSubmodule(ref id) => {
|
GitSubmodule(id) => {
|
||||||
state.update(&3u32.to_le_bytes());
|
state.update(&3u32.to_le_bytes());
|
||||||
id.hash(state);
|
id.hash(state);
|
||||||
}
|
}
|
||||||
Conflict(ref id) => {
|
Conflict(id) => {
|
||||||
state.update(&4u32.to_le_bytes());
|
state.update(&4u32.to_le_bytes());
|
||||||
id.hash(state);
|
id.hash(state);
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ impl ContentHash for String {
|
|||||||
|
|
||||||
impl<T: ContentHash> ContentHash for Option<T> {
|
impl<T: ContentHash> ContentHash for Option<T> {
|
||||||
fn hash(&self, state: &mut impl digest::Update) {
|
fn hash(&self, state: &mut impl digest::Update) {
|
||||||
match *self {
|
match self {
|
||||||
None => state.update(&[0]),
|
None => state.update(&[0]),
|
||||||
Some(ref x) => {
|
Some(x) => {
|
||||||
state.update(&[1]);
|
state.update(&[1]);
|
||||||
x.hash(state)
|
x.hash(state)
|
||||||
}
|
}
|
||||||
|
@ -125,15 +125,12 @@ pub enum RefTarget {
|
|||||||
impl ContentHash for RefTarget {
|
impl ContentHash for RefTarget {
|
||||||
fn hash(&self, state: &mut impl digest::Update) {
|
fn hash(&self, state: &mut impl digest::Update) {
|
||||||
use RefTarget::*;
|
use RefTarget::*;
|
||||||
match *self {
|
match self {
|
||||||
Normal(ref id) => {
|
Normal(id) => {
|
||||||
state.update(&0u32.to_le_bytes());
|
state.update(&0u32.to_le_bytes());
|
||||||
id.hash(state);
|
id.hash(state);
|
||||||
}
|
}
|
||||||
Conflict {
|
Conflict { removes, adds } => {
|
||||||
ref removes,
|
|
||||||
ref adds,
|
|
||||||
} => {
|
|
||||||
state.update(&1u32.to_le_bytes());
|
state.update(&1u32.to_le_bytes());
|
||||||
removes.hash(state);
|
removes.hash(state);
|
||||||
adds.hash(state);
|
adds.hash(state);
|
||||||
|
@ -181,13 +181,13 @@ impl TSerializable for RefTarget {
|
|||||||
fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
|
fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
|
||||||
let struct_ident = TStructIdentifier::new("RefTarget");
|
let struct_ident = TStructIdentifier::new("RefTarget");
|
||||||
o_prot.write_struct_begin(&struct_ident)?;
|
o_prot.write_struct_begin(&struct_ident)?;
|
||||||
match *self {
|
match self {
|
||||||
RefTarget::CommitId(ref f) => {
|
RefTarget::CommitId(f) => {
|
||||||
o_prot.write_field_begin(&TFieldIdentifier::new("commit_id", TType::String, 1))?;
|
o_prot.write_field_begin(&TFieldIdentifier::new("commit_id", TType::String, 1))?;
|
||||||
o_prot.write_bytes(f)?;
|
o_prot.write_bytes(f)?;
|
||||||
o_prot.write_field_end()?;
|
o_prot.write_field_end()?;
|
||||||
},
|
},
|
||||||
RefTarget::Conflict(ref f) => {
|
RefTarget::Conflict(f) => {
|
||||||
o_prot.write_field_begin(&TFieldIdentifier::new("conflict", TType::Struct, 2))?;
|
o_prot.write_field_begin(&TFieldIdentifier::new("conflict", TType::Struct, 2))?;
|
||||||
f.write_to_out_protocol(o_prot)?;
|
f.write_to_out_protocol(o_prot)?;
|
||||||
o_prot.write_field_end()?;
|
o_prot.write_field_end()?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user