@@ -1560,7 +1560,8 @@ impl<'de, 'a, R: Read<'de>> de::Deserializer<'de> for &'a mut Deserializer<R> {
15601560 ///
15611561 /// # Examples
15621562 ///
1563- /// You can use this to parse JSON strings containing invalid UTF-8 bytes.
1563+ /// You can use this to parse JSON strings containing invalid UTF-8 bytes,
1564+ /// or unpaired surrogates.
15641565 ///
15651566 /// ```
15661567 /// use serde_bytes::ByteBuf;
@@ -1580,21 +1581,18 @@ impl<'de, 'a, R: Read<'de>> de::Deserializer<'de> for &'a mut Deserializer<R> {
15801581 /// ```
15811582 ///
15821583 /// Backslash escape sequences like `\n` are still interpreted and required
1583- /// to be valid. `\u` escape sequences are required to represent valid
1584- /// Unicode code points, except in the case of lone surrogates .
1584+ /// to be valid. `\u` escape sequences are required to represent a valid
1585+ /// Unicode code point or lone surrogate .
15851586 ///
15861587 /// ```
15871588 /// use serde_bytes::ByteBuf;
15881589 ///
1589- /// fn look_at_bytes() {
1590+ /// fn look_at_bytes() -> Result<(), serde_json::Error> {
15901591 /// let json_data = b"\"lone surrogate: \\uD801\"";
1591- /// let parsed: Result<ByteBuf, _> = serde_json::from_slice(json_data);
1592- ///
1593- /// assert!(parsed.is_ok());
1594- ///
1592+ /// let bytes: ByteBuf = serde_json::from_slice(json_data)?;
15951593 /// let expected = b"lone surrogate: \xED\xA0\x81";
1596- /// let bytes: ByteBuf = parsed.unwrap( );
1597- /// assert_eq!(expected, &bytes[..]);
1594+ /// assert_eq!(expected, bytes.as_slice() );
1595+ /// Ok(())
15981596 /// }
15991597 /// #
16001598 /// # look_at_bytes();
0 commit comments