mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-11-06 09:11:07 +00:00
Improved support for byte strings
This commit is contained in:
1 parent
af752ddcb5
commit
875610044f
5 files changed
+124
-3
No files matched your search
@@ -578,6 +578,16 @@ fn deserialize_field_visitor(
|
||||
_ => Err(::serde::de::Error::unknown_field_error(value)),
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_bytes<E>(&mut self, value: &[u8]) -> ::std::result::Result<__Field, E>
|
||||
where E: ::serde::de::Error,
|
||||
{
|
||||
// TODO: would be better to generate a byte string literal match
|
||||
match ::std::str::from_utf8(value) {
|
||||
Ok(s) => self.visit_str(s),
|
||||
_ => Err(::serde::de::Error::syntax_error()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.visit(__FieldVisitor)
|
||||
|
||||
Reference in new issue
Block a user