From ea0012fc5a56fc754a8db5241cbd5e24e7332d08 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 12 May 2018 09:44:04 -0700 Subject: [PATCH] Support deserializing bytes as the flattened identifier --- serde/src/private/de.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs index fab85534..de5b57b2 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -276,6 +276,8 @@ mod content { match *self { Content::Str(x) => Some(x), Content::String(ref x) => Some(x), + Content::Bytes(x) => str::from_utf8(x).ok(), + Content::ByteBuf(ref x) => str::from_utf8(x).ok(), _ => None, } } @@ -1423,6 +1425,8 @@ mod content { match self.content { Content::String(v) => visitor.visit_string(v), Content::Str(v) => visitor.visit_borrowed_str(v), + Content::ByteBuf(v) => visitor.visit_byte_buf(v), + Content::Bytes(v) => visitor.visit_borrowed_bytes(v), _ => Err(self.invalid_type(&visitor)), } } @@ -2123,6 +2127,8 @@ mod content { match *self.content { Content::String(ref v) => visitor.visit_str(v), Content::Str(v) => visitor.visit_borrowed_str(v), + Content::ByteBuf(ref v) => visitor.visit_bytes(v), + Content::Bytes(v) => visitor.visit_borrowed_bytes(v), _ => Err(self.invalid_type(&visitor)), } }