@@ -1560,7 +1560,8 @@ impl<'de, 'a, R: Read<'de>> de::Deserializer<'de> for &'a mut Deserializer<R> {
1560
1560
///
1561
1561
/// # Examples
1562
1562
///
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.
1564
1565
///
1565
1566
/// ```
1566
1567
/// use serde_bytes::ByteBuf;
@@ -1580,21 +1581,18 @@ impl<'de, 'a, R: Read<'de>> de::Deserializer<'de> for &'a mut Deserializer<R> {
1580
1581
/// ```
1581
1582
///
1582
1583
/// 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 .
1585
1586
///
1586
1587
/// ```
1587
1588
/// use serde_bytes::ByteBuf;
1588
1589
///
1589
- /// fn look_at_bytes() {
1590
+ /// fn look_at_bytes() -> Result<(), serde_json::Error> {
1590
1591
/// 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)?;
1595
1593
/// 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(())
1598
1596
/// }
1599
1597
/// #
1600
1598
/// # look_at_bytes();
0 commit comments