From 78ee34f9a6edf01138bbbd501413c011443c17bd Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 10 Aug 2019 02:39:13 +0000 Subject: [PATCH] Simplified some Rust methods to be pass-by-copy-value instead of pass-by-reference, thanks to clippy (linter)'s suggestions. --- rust/src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 147b542..7cfd653 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -917,9 +917,9 @@ pub enum QrCodeEcc { impl QrCodeEcc { // Returns an unsigned 2-bit integer (in the range 0 to 3). - fn ordinal(&self) -> usize { + fn ordinal(self) -> usize { use QrCodeEcc::*; - match *self { + match self { Low => 0, Medium => 1, Quartile => 2, @@ -929,9 +929,9 @@ impl QrCodeEcc { // Returns an unsigned 2-bit integer (in the range 0 to 3). - fn format_bits(&self) -> u32 { + fn format_bits(self) -> u32 { use QrCodeEcc::*; - match *self { + match self { Low => 1, Medium => 0, Quartile => 3, @@ -1176,9 +1176,9 @@ impl QrSegmentMode { // Returns an unsigned 4-bit integer value (range 0 to 15) // representing the mode indicator bits for this mode object. - fn mode_bits(&self) -> u32 { + fn mode_bits(self) -> u32 { use QrSegmentMode::*; - match *self { + match self { Numeric => 0x1, Alphanumeric => 0x2, Byte => 0x4, @@ -1190,9 +1190,9 @@ impl QrSegmentMode { // Returns the bit width of the character count field for a segment in this mode // in a QR Code at the given version number. The result is in the range [0, 16]. - fn num_char_count_bits(&self, ver: Version) -> u8 { + fn num_char_count_bits(self, ver: Version) -> u8 { use QrSegmentMode::*; - (match *self { + (match self { Numeric => [10, 12, 14], Alphanumeric => [ 9, 11, 13], Byte => [ 8, 16, 16], @@ -1269,7 +1269,7 @@ impl Version { } /// Returns the value, which is in the range [1, 40]. - pub fn value(&self) -> u8 { + pub fn value(self) -> u8 { self.0 } } @@ -1289,7 +1289,7 @@ impl Mask { } /// Returns the value, which is in the range [0, 7]. - pub fn value(&self) -> u8 { + pub fn value(self) -> u8 { self.0 } }