diff options
author | Nick Hackman <snickhackman@gmail.com> | 2019-08-13 14:13:01 -0400 |
---|---|---|
committer | Nick Hackman <snickhackman@gmail.com> | 2019-08-13 14:13:01 -0400 |
commit | f883457334fee8006752256e96171a4b4a428883 (patch) | |
tree | 97d7448d1b39e4a0de74033c27036f02fcac5698 /src/de.rs | |
parent | 208f4a9ce9178a4233f1886c2fdfae05e001a2d0 (diff) | |
download | milf-rs-f883457334fee8006752256e96171a4b4a428883.tar.gz milf-rs-f883457334fee8006752256e96171a4b4a428883.zip |
Simplified Logic when comparing discriminants
Removed matches that were used to compare Enum variants for equality in
favor of using discriminant from https://doc.rust-lang.org/std/mem/fn.discriminant.html
introduced in Rust 1.21.0
Diffstat (limited to 'src/de.rs')
-rw-r--r-- | src/de.rs | 14 |
1 files changed, 2 insertions, 12 deletions
@@ -8,6 +8,7 @@ use std::borrow::Cow; use std::error; use std::f64; use std::fmt; +use std::mem::discriminant; use std::str; use std::vec; @@ -2057,17 +2058,6 @@ impl<'a> E<'a> { impl<'a> Value<'a> { fn same_type(&self, other: &Value<'a>) -> bool { - match (&self.e, &other.e) { - (&E::String(..), &E::String(..)) - | (&E::Integer(..), &E::Integer(..)) - | (&E::Float(..), &E::Float(..)) - | (&E::Boolean(..), &E::Boolean(..)) - | (&E::Datetime(..), &E::Datetime(..)) - | (&E::Array(..), &E::Array(..)) - | (&E::InlineTable(..), &E::InlineTable(..)) => true, - (&E::DottedTable(..), &E::DottedTable(..)) => true, - - _ => false, - } + discriminant(&self.e) == discriminant(&other.e) } } |