mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 18:03:51 +01:00
Use serde to deserialize Tagged<Value>
This commit is contained in:
parent
9ba2e75ac1
commit
cc8872b4ee
@ -24,14 +24,6 @@ impl<T: ExtractType> ExtractType for Tagged<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtractType for Value {
|
||||
fn extract(value: &Tagged<Value>) -> Result<Value, ShellError> {
|
||||
trace!("<Tagged> Extracting {:?} for Value", value);
|
||||
|
||||
Ok(value.item().clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtractType for bool {
|
||||
fn extract(value: &Tagged<Value>) -> Result<bool, ShellError> {
|
||||
trace!("Extracting {:?} for bool", value);
|
||||
|
@ -323,6 +323,13 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> {
|
||||
|
||||
let value = self.pop();
|
||||
|
||||
let type_name = std::any::type_name::<V::Value>();
|
||||
let tagged_val_name = std::any::type_name::<Tagged<Value>>();
|
||||
|
||||
if name == tagged_val_name {
|
||||
return visit::<Tagged<Value>, _>(value.val, name, fields, visitor);
|
||||
}
|
||||
|
||||
if name == "Block" {
|
||||
let block = match value.val {
|
||||
Tagged {
|
||||
@ -331,11 +338,10 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> {
|
||||
} => block,
|
||||
other => return Err(ShellError::type_error("Block", other.tagged_type_name())),
|
||||
};
|
||||
return visit(block, name, fields, visitor);
|
||||
return visit::<value::Block, _>(block, name, fields, visitor);
|
||||
}
|
||||
|
||||
let name = std::any::type_name::<V::Value>();
|
||||
trace!("Extracting {:?} for {:?}", value.val, name);
|
||||
trace!("Extracting {:?} for {:?}", value.val, type_name);
|
||||
V::Value::extract(&value.val)
|
||||
}
|
||||
fn deserialize_enum<V>(
|
||||
|
Loading…
Reference in New Issue
Block a user