diff --git a/src/de.rs b/src/de.rs index 8f0c619b..3edac778 100644 --- a/src/de.rs +++ b/src/de.rs @@ -16,9 +16,6 @@ impl<'de> de::Deserializer<'de> for Value { // Deserialize based on the underlying type match self.kind { ValueKind::Nil => visitor.visit_unit(), - ValueKind::I8(i) => visitor.visit_i8(i), - ValueKind::I16(i) => visitor.visit_i16(i), - ValueKind::I32(i) => visitor.visit_i32(i), ValueKind::I64(i) => visitor.visit_i64(i), ValueKind::I128(i) => visitor.visit_i128(i), ValueKind::Boolean(b) => visitor.visit_bool(b), @@ -352,9 +349,6 @@ impl<'de> de::Deserializer<'de> for Config { // Deserialize based on the underlying type match self.cache.kind { ValueKind::Nil => visitor.visit_unit(), - ValueKind::I8(i) => visitor.visit_i8(i), - ValueKind::I16(i) => visitor.visit_i16(i), - ValueKind::I32(i) => visitor.visit_i32(i), ValueKind::I64(i) => visitor.visit_i64(i), ValueKind::I128(i) => visitor.visit_i128(i), ValueKind::Boolean(b) => visitor.visit_bool(b), diff --git a/src/error.rs b/src/error.rs index 7447613c..01d3bd19 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,9 +9,6 @@ use std::result; #[derive(Debug)] pub enum Unexpected { Bool(bool), - I8(i8), - I16(i16), - I32(i32), I64(i64), I128(i128), Float(f64), @@ -25,9 +22,6 @@ impl fmt::Display for Unexpected { fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> { match *self { Unexpected::Bool(b) => write!(f, "boolean `{}`", b), - Unexpected::I8(i) => write!(f, "integer 8 bit `{}`", i), - Unexpected::I16(i) => write!(f, "integer 16 bit `{}`", i), - Unexpected::I32(i) => write!(f, "integer 32 bit `{}`", i), Unexpected::I64(i) => write!(f, "integer 64 bit `{}`", i), Unexpected::I128(i) => write!(f, "integer 128 bit `{}`", i), Unexpected::Float(v) => write!(f, "floating point `{}`", v), diff --git a/src/value.rs b/src/value.rs index f514b44c..9fb95743 100644 --- a/src/value.rs +++ b/src/value.rs @@ -9,9 +9,6 @@ use std::fmt::Display; pub enum ValueKind { Nil, Boolean(bool), - I8(i8), - I16(i16), - I32(i32), I64(i64), I128(i128), Float(f64), @@ -55,19 +52,19 @@ impl<'a> From<&'a str> for ValueKind { impl From for ValueKind { fn from(value: i8) -> Self { - ValueKind::I8(value) + ValueKind::I64(value as i64) } } impl From for ValueKind { fn from(value: i16) -> Self { - ValueKind::I16(value) + ValueKind::I64(value as i64) } } impl From for ValueKind { fn from(value: i32) -> Self { - ValueKind::I32(value) + ValueKind::I64(value as i64) } } @@ -130,9 +127,6 @@ impl Display for ValueKind { match *self { ValueKind::String(ref value) => write!(f, "{}", value), ValueKind::Boolean(value) => write!(f, "{}", value), - ValueKind::I8(value) => write!(f, "{}", value), - ValueKind::I16(value) => write!(f, "{}", value), - ValueKind::I32(value) => write!(f, "{}", value), ValueKind::I64(value) => write!(f, "{}", value), ValueKind::I128(value) => write!(f, "{}", value), ValueKind::Float(value) => write!(f, "{}", value), @@ -192,9 +186,6 @@ impl Value { pub fn into_bool(self) -> Result { match self.kind { ValueKind::Boolean(value) => Ok(value), - ValueKind::I8(value) => Ok(value != 0), - ValueKind::I16(value) => Ok(value != 0), - ValueKind::I32(value) => Ok(value != 0), ValueKind::I64(value) => Ok(value != 0), ValueKind::I128(value) => Ok(value != 0), ValueKind::Float(value) => Ok(value != 0.0), @@ -236,9 +227,6 @@ impl Value { // FIXME: Should this not be `try_into_*` ? pub fn into_int(self) -> Result { match self.kind { - ValueKind::I8(value) => Ok(value as i64), - ValueKind::I16(value) => Ok(value as i64), - ValueKind::I32(value) => Ok(value as i64), ValueKind::I64(value) => Ok(value), ValueKind::I128(value) => Err(ConfigError::invalid_type( self.origin, @@ -288,9 +276,6 @@ impl Value { /// Returns `self` into an i128, if possible. pub fn into_int128(self) -> Result { match self.kind { - ValueKind::I8(value) => Ok(value as i128), - ValueKind::I16(value) => Ok(value as i128), - ValueKind::I32(value) => Ok(value as i128), ValueKind::I64(value) => Ok(value as i128), ValueKind::I128(value) => Ok(value), @@ -356,9 +341,6 @@ impl Value { } } - ValueKind::I8(value) => Ok(value as f64), - ValueKind::I16(value) => Ok(value as f64), - ValueKind::I32(value) => Ok(value as f64), ValueKind::I64(value) => Ok(value as f64), ValueKind::I128(value) => Ok(value as f64), ValueKind::Boolean(value) => Ok(if value { 1.0 } else { 0.0 }), @@ -389,9 +371,6 @@ impl Value { ValueKind::String(value) => Ok(value), ValueKind::Boolean(value) => Ok(value.to_string()), - ValueKind::I8(value) => Ok(value.to_string()), - ValueKind::I16(value) => Ok(value.to_string()), - ValueKind::I32(value) => Ok(value.to_string()), ValueKind::I64(value) => Ok(value.to_string()), ValueKind::I128(value) => Ok(value.to_string()), ValueKind::Float(value) => Ok(value.to_string()), @@ -432,21 +411,6 @@ impl Value { Unexpected::Str(value), "an array", )), - ValueKind::I8(value) => Err(ConfigError::invalid_type( - self.origin, - Unexpected::I8(value), - "an array", - )), - ValueKind::I16(value) => Err(ConfigError::invalid_type( - self.origin, - Unexpected::I16(value), - "an array", - )), - ValueKind::I32(value) => Err(ConfigError::invalid_type( - self.origin, - Unexpected::I32(value), - "an array", - )), ValueKind::I64(value) => Err(ConfigError::invalid_type( self.origin, Unexpected::I64(value), @@ -492,21 +456,6 @@ impl Value { Unexpected::Str(value), "a map", )), - ValueKind::I8(value) => Err(ConfigError::invalid_type( - self.origin, - Unexpected::I8(value), - "a map", - )), - ValueKind::I16(value) => Err(ConfigError::invalid_type( - self.origin, - Unexpected::I16(value), - "a map", - )), - ValueKind::I32(value) => Err(ConfigError::invalid_type( - self.origin, - Unexpected::I32(value), - "a map", - )), ValueKind::I64(value) => Err(ConfigError::invalid_type( self.origin, Unexpected::I64(value), @@ -558,17 +507,17 @@ impl<'de> Deserialize<'de> for Value { #[inline] fn visit_i8(self, value: i8) -> ::std::result::Result { - Ok((value).into()) + Ok((value as i64).into()) } #[inline] fn visit_i16(self, value: i16) -> ::std::result::Result { - Ok((value).into()) + Ok((value as i64).into()) } #[inline] fn visit_i32(self, value: i32) -> ::std::result::Result { - Ok((value).into()) + Ok((value as i64).into()) } #[inline]