@@ -481,7 +481,32 @@ impl<'de, 'a> SeqAccess<'de> for ListIter<'de, 'a> {
481481/// - attribute values (`<... ...="value" ...>`)
482482/// - mixed text / CDATA content (`<...>text<![CDATA[cdata]]></...>`)
483483///
484+ /// This deserializer processes items as following:
485+ /// - numbers are parsed from a text content using [`FromStr`];
486+ /// - booleans converted from the text according to the XML [specification]:
487+ /// - `"true"` and `"1"` converted to `true`;
488+ /// - `"false"` and `"0"` converted to `false`;
489+ /// - strings returned as is;
490+ /// - characters also returned as strings. If string contain more than one character
491+ /// or empty, it is responsibility of a type to return an error;
492+ /// - `Option` always deserialized as `Some` using the same deserializer.
493+ /// If attribute or text content is missed, then the deserializer even wouldn't
494+ /// be used, so if it is used, then the value should be;
495+ /// - units (`()`) and unit structs always deserialized successfully;
496+ /// - newtype structs forwards deserialization to the inner type using the same
497+ /// deserializer;
498+ /// - sequences, tuples and tuple structs are deserialized as `xs:list`s. Only
499+ /// sequences of primitive types is possible to deserialize this way and they
500+ /// should be delimited by a space (` `, `\t`, `\r`, or `\n`);
501+ /// - structs and maps returns [`DeError::Unsupported`];
502+ /// - enums:
503+ /// - unit variants: just return `()`;
504+ /// - all other variants returns [`DeError::Unsupported`];
505+ /// - identifiers are deserialized as strings.
506+ ///
484507/// [simple types]: https://www.w3.org/TR/xmlschema11-1/#Simple_Type_Definition
508+ /// [`FromStr`]: std::str::FromStr
509+ /// [specification]: https://www.w3.org/TR/xmlschema11-2/#boolean
485510pub struct SimpleTypeDeserializer < ' de , ' a > {
486511 /// - In case of attribute contains escaped attribute value
487512 /// - In case of text contains unescaped text value
@@ -642,11 +667,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
642667 where
643668 V : Visitor < ' de > ,
644669 {
645- if self . content . is_empty ( ) {
646- visitor. visit_none ( )
647- } else {
648- visitor. visit_some ( self )
649- }
670+ visitor. visit_some ( self )
650671 }
651672
652673 fn deserialize_unit < V > ( self , visitor : V ) -> Result < V :: Value , Self :: Error >
@@ -1225,7 +1246,7 @@ mod tests {
12251246 err ! ( utf8, borrowed_bytes: Bytes = "<escaped string"
12261247 => Unsupported ( "binary data content is not supported by XML format" ) ) ;
12271248
1228- simple ! ( utf8, option_none: Option <& str > = "" => None ) ;
1249+ simple ! ( utf8, option_none: Option <& str > = "" => Some ( "" ) ) ;
12291250 simple ! ( utf8, option_some: Option <& str > = "non-escaped string" => Some ( "non-escaped string" ) ) ;
12301251
12311252 simple_only ! ( utf8, unit: ( ) = "any data" => ( ) ) ;
@@ -1311,7 +1332,7 @@ mod tests {
13111332 unsupported ! ( borrowed_bytes: Bytes = "<escaped string"
13121333 => "binary data content is not supported by XML format" ) ;
13131334
1314- utf16 ! ( option_none: Option <( ) > = "" => None ) ;
1335+ utf16 ! ( option_none: Option <( ) > = "" => Some ( ( ) ) ) ;
13151336 utf16 ! ( option_some: Option <( ) > = "any data" => Some ( ( ) ) ) ;
13161337
13171338 utf16 ! ( unit: ( ) = "any data" => ( ) ) ;
0 commit comments