value: add TryFrom for Vec<Value>

This commit is contained in:
Matt Bilker
2019-01-23 10:29:15 +00:00
parent 6c7574d007
commit c174d13893

View File

@@ -621,6 +621,18 @@ impl Value {
}
}
#[cfg(feature = "try_from")]
impl TryFrom<Value> for Vec<Value> {
type Error = KbinError;
fn try_from(value: Value) -> Result<Self, Self::Error> {
match value {
Value::Array(_, values) => Ok(values),
value => Err(KbinErrorKind::ExpectedValueArray(value).into()),
}
}
}
#[cfg(feature = "try_from")]
impl TryFrom<Value> for Vec<u8> {
type Error = KbinError;