From 54cab71bd7a4816d12b6aa05104c4481d68f2fc1 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Thu, 14 Dec 2017 17:23:59 -0800 Subject: [PATCH] Engine option equality done...finally --- src/lib.rs | 7 +------ src/options.rs | 6 +++--- tests/lib.rs | 20 +++++++++++++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8ba9e47..d65a971 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,12 +53,7 @@ where { pub fn new(name: &'a str, author: &'a str, reader: R, writer: W, engine_options: Vec) -> Engine<'a, R, W> { - Engine { - name: name, - author: author, - reader: reader, - writer: writer, - engine_options: engine_options, + Engine { name, author, reader, writer, engine_options, } } diff --git a/src/options.rs b/src/options.rs index 826c55c..56c63bc 100644 --- a/src/options.rs +++ b/src/options.rs @@ -46,7 +46,7 @@ pub mod constants { } /// The `EngineOptionType` type used to indicate what type of option the GUI should display -#[derive(Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] pub enum EngineOptionType { Check, Spin, @@ -64,7 +64,7 @@ pub enum EngineOptionData { Text(String), } -#[derive(Debug, Hash, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] /// The `EngineOptionDataType` type used to indicate the type of the `EngineOption` setting pub enum EngineOptionDataType { DefaultVal, // `Default` is reserved so `DefaultVal` is used @@ -86,7 +86,7 @@ impl EngineOption { /// Constructs a new EngineOption of type T pub fn new(name: &'static str, option_type: EngineOptionType, option_data: HashMap) -> EngineOption { - EngineOption { name, option_type, option_data } + EngineOption { name, option_type, option_data, } } pub fn option_string(&self) -> String { diff --git a/tests/lib.rs b/tests/lib.rs index dbc3d7d..8e8104d 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -50,14 +50,28 @@ fn send_readyok() { fn engine_option_equality() { let name = constants::HASH; let option_type = EngineOptionType::Check; - let option_data = + let option_data1 = [(EngineOptionDataType::DefaultVal, EngineOptionData::Int(1)), (EngineOptionDataType::Min, EngineOptionData::Int(1)), (EngineOptionDataType::Max, EngineOptionData::Int(128)) ].iter().cloned().collect(); + let option_data2 = + [(EngineOptionDataType::DefaultVal, EngineOptionData::Int(1)), + (EngineOptionDataType::Min, EngineOptionData::Int(1)), + (EngineOptionDataType::Max, EngineOptionData::Int(128)) + ].iter().cloned().collect(); + + let o1 = EngineOption { + name: name, + option_type: option_type, + option_data: option_data1, + }; - let o1 = EngineOption { name, option_type, option_data }; - let o2 = EngineOption { name, option_type, option_data }; + let o2 = EngineOption { + name: name, + option_type: option_type, + option_data: option_data2, + }; assert_eq!(o1, o2); }