diff options
Diffstat (limited to 'src/value.rs')
-rw-r--r-- | src/value.rs | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/src/value.rs b/src/value.rs index 1bba78c..2db195d 100644 --- a/src/value.rs +++ b/src/value.rs @@ -542,58 +542,3 @@ impl Display for Value { write!(f, "{}", self.kind) } } - -pub struct ValueWithKey<'a>(pub Value, &'a str); - -impl<'a> ValueWithKey<'a> { - pub fn new(value: Value, key: &'a str) -> Self { - ValueWithKey(value, key) - } - - pub fn into_bool(self) -> Result<bool> { - match self.0.into_bool() { - Ok(value) => Ok(value), - Err(error) => Err(error.extend_with_key(self.1)), - } - } - - /// Returns `self` into an i64, if possible. - pub fn into_int(self) -> Result<i64> { - match self.0.into_int() { - Ok(value) => Ok(value), - Err(error) => Err(error.extend_with_key(self.1)), - } - } - - /// Returns `self` into a f64, if possible. - pub fn into_float(self) -> Result<f64> { - match self.0.into_float() { - Ok(value) => Ok(value), - Err(error) => Err(error.extend_with_key(self.1)), - } - } - - /// Returns `self` into a str, if possible. - pub fn into_str(self) -> Result<String> { - match self.0.into_str() { - Ok(value) => Ok(value), - Err(error) => Err(error.extend_with_key(self.1)), - } - } - - /// Returns `self` into an array, if possible - pub fn into_array(self) -> Result<Vec<Value>> { - match self.0.into_array() { - Ok(value) => Ok(value), - Err(error) => Err(error.extend_with_key(self.1)), - } - } - - /// If the `Value` is a Table, returns the associated Map. - pub fn into_table(self) -> Result<HashMap<String, Value>> { - match self.0.into_table() { - Ok(value) => Ok(value), - Err(error) => Err(error.extend_with_key(self.1)), - } - } -} |