fixed some clippy errors

This commit is contained in:
Frederik Palmø 2021-12-18 14:34:54 +01:00
parent dab05d78e2
commit 57e0e51d7c
4 changed files with 21 additions and 22 deletions

View file

@ -159,7 +159,7 @@ mod tests {
let enigma_machine = Enigma::new(rotors, plugboard, reflector); let enigma_machine = Enigma::new(rotors, plugboard, reflector);
let mut em1 = enigma_machine.clone(); let mut em1 = enigma_machine.clone();
let mut em2 = enigma_machine.clone(); let mut em2 = enigma_machine;
println!("Encoding string"); println!("Encoding string");
let result = em1 let result = em1

View file

@ -72,8 +72,8 @@ impl fmt::Display for Plugboard {
let right_letter = *mapping; let right_letter = *mapping;
if left_letter != right_letter if left_letter != right_letter
&& !pairs.get(&left_letter).is_some() && pairs.get(&left_letter).is_none()
&& !pairs.get(&right_letter).is_some() && pairs.get(&right_letter).is_none()
{ {
pairs.insert(left_letter, right_letter); pairs.insert(left_letter, right_letter);
} }

View file

@ -49,14 +49,14 @@ impl Reflector {
} }
} }
const VARIANT_IDENTITY: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const VARIANT_IDENTITY: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const VARIANT_BETA: &'static str = "LEYJVCNIXWPBQMDRTAKZGFUHOS"; const VARIANT_BETA: &str = "LEYJVCNIXWPBQMDRTAKZGFUHOS";
const VARIANT_GAMMA: &'static str = "FSOKANUERHMBTIYCWLQPZXVGJD"; const VARIANT_GAMMA: &str = "FSOKANUERHMBTIYCWLQPZXVGJD";
const VARIANT_A: &'static str = "EJMZALYXVBWFCRQUONTSPIKHGD"; const VARIANT_A: &str = "EJMZALYXVBWFCRQUONTSPIKHGD";
const VARIANT_B: &'static str = "YRUHQSLDPXNGOKMIEBFZCWVJAT"; const VARIANT_B: &str = "YRUHQSLDPXNGOKMIEBFZCWVJAT";
const VARIANT_C: &'static str = "FVPJIAOYEDRZXWGCTKUQSBNMHL"; const VARIANT_C: &str = "FVPJIAOYEDRZXWGCTKUQSBNMHL";
const VARIANT_B_THIN: &'static str = "ENKQAUYWJICOPBLMDXZVFTHRGS"; const VARIANT_B_THIN: &str = "ENKQAUYWJICOPBLMDXZVFTHRGS";
const VARIANT_C_THIN: &'static str = "RDOBJNTKVEHMLFCWZAXGYIPSUQ"; const VARIANT_C_THIN: &str = "RDOBJNTKVEHMLFCWZAXGYIPSUQ";
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum ReflectorVariant { pub enum ReflectorVariant {

View file

@ -64,8 +64,7 @@ impl Rotor {
self.mappings self.mappings
.iter() .iter()
.enumerate() .enumerate()
.filter(|(_, l)| (**l - self.position) == letter) .find(|(_, l)| (**l - self.position) == letter)
.next()
.unwrap() .unwrap()
.0, .0,
) - self.position ) - self.position
@ -80,15 +79,15 @@ impl Rotor {
} }
} }
const IDENTITY: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const IDENTITY: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const VARIANT_I: &'static str = "EKMFLGDQVZNTOWYHXUSPAIBRCJ"; const VARIANT_I: &str = "EKMFLGDQVZNTOWYHXUSPAIBRCJ";
const VARIANT_II: &'static str = "AJDKSIRUXBLHWTMCQGZNPYFVOE"; const VARIANT_II: &str = "AJDKSIRUXBLHWTMCQGZNPYFVOE";
const VARIANT_III: &'static str = "BDFHJLCPRTXVZNYEIWGAKMUSQO"; const VARIANT_III: &str = "BDFHJLCPRTXVZNYEIWGAKMUSQO";
const VARIANT_IV: &'static str = "ESOVPZJAYQUIRHXLNFTGKDCMWB"; const VARIANT_IV: &str = "ESOVPZJAYQUIRHXLNFTGKDCMWB";
const VARIANT_V: &'static str = "VZBRGITYUPSDNHLXAWMJQOFECK"; const VARIANT_V: &str = "VZBRGITYUPSDNHLXAWMJQOFECK";
const VARIANT_VI: &'static str = "JPGVOUMFYQBENHZRDKASXLICTW"; const VARIANT_VI: &str = "JPGVOUMFYQBENHZRDKASXLICTW";
const VARIANT_VII: &'static str = "NZJHGRCXMYSWBOUFAIVLPEKQDT"; const VARIANT_VII: &str = "NZJHGRCXMYSWBOUFAIVLPEKQDT";
const VARIANT_VIII: &'static str = "FKQHTLXOCBJSPDZRAMEWNIUYGV"; const VARIANT_VIII: &str = "FKQHTLXOCBJSPDZRAMEWNIUYGV";
#[non_exhaustive] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]