Skip to content

Commit 96f9d47

Browse files
author
daniel.eades
committed
use 'Self'
1 parent 752a46d commit 96f9d47

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/alphabet.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ pub enum ParseAlphabetError {
121121
impl fmt::Display for ParseAlphabetError {
122122
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
123123
match self {
124-
ParseAlphabetError::InvalidLength => write!(f, "Invalid length - must be 64 bytes"),
125-
ParseAlphabetError::DuplicatedByte(b) => write!(f, "Duplicated byte: {:#04x}", b),
126-
ParseAlphabetError::UnprintableByte(b) => write!(f, "Unprintable byte: {:#04x}", b),
127-
ParseAlphabetError::ReservedByte(b) => write!(f, "Reserved byte: {:#04x}", b),
124+
Self::InvalidLength => write!(f, "Invalid length - must be 64 bytes"),
125+
Self::DuplicatedByte(b) => write!(f, "Duplicated byte: {:#04x}", b),
126+
Self::UnprintableByte(b) => write!(f, "Unprintable byte: {:#04x}", b),
127+
Self::ReservedByte(b) => write!(f, "Reserved byte: {:#04x}", b),
128128
}
129129
}
130130
}

src/decode.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ pub enum DecodeError {
3030
impl fmt::Display for DecodeError {
3131
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3232
match *self {
33-
DecodeError::InvalidByte(index, byte) => {
34-
write!(f, "Invalid byte {}, offset {}.", byte, index)
35-
}
36-
DecodeError::InvalidLength => write!(f, "Encoded text cannot have a 6-bit remainder."),
37-
DecodeError::InvalidLastSymbol(index, byte) => {
33+
Self::InvalidByte(index, byte) => write!(f, "Invalid byte {}, offset {}.", byte, index),
34+
Self::InvalidLength => write!(f, "Encoded text cannot have a 6-bit remainder."),
35+
Self::InvalidLastSymbol(index, byte) => {
3836
write!(f, "Invalid last symbol {}, offset {}.", byte, index)
3937
}
4038
}
@@ -45,9 +43,9 @@ impl fmt::Display for DecodeError {
4543
impl error::Error for DecodeError {
4644
fn description(&self) -> &str {
4745
match *self {
48-
DecodeError::InvalidByte(_, _) => "invalid byte",
49-
DecodeError::InvalidLength => "invalid length",
50-
DecodeError::InvalidLastSymbol(_, _) => "invalid last symbol",
46+
Self::InvalidByte(_, _) => "invalid byte",
47+
Self::InvalidLength => "invalid length",
48+
Self::InvalidLastSymbol(_, _) => "invalid last symbol",
5149
}
5250
}
5351

0 commit comments

Comments
 (0)