mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-16 12:44: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 {
|
||||
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);
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ impl ContentHash for String {
|
||||
|
||||
impl<T: ContentHash> ContentHash for Option<T> {
|
||||
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)
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user