22
33use core:: fmt;
44
5- #[ derive( Debug ) ]
65/// A fragment of an escaped string
6+ #[ derive( Debug ) ]
7+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
78pub enum EscapedStringFragment < ' a > {
89 /// A series of characters which weren't escaped in the input.
910 NotEscaped ( & ' a str ) ,
1011 /// A character which was escaped in the input.
1112 Escaped ( char ) ,
1213}
1314
14- #[ derive( Debug ) ]
1515/// Errors occuring while unescaping strings.
16+ #[ derive( Debug ) ]
17+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
1618pub enum StringUnescapeError {
1719 /// Failed to unescape a character due to an invalid escape sequence.
1820 InvalidEscapeSequence ,
@@ -23,7 +25,7 @@ impl fmt::Display for StringUnescapeError {
2325 match self {
2426 StringUnescapeError :: InvalidEscapeSequence => write ! (
2527 f,
26- "Failed to unescape a character due to an invalid escape sequence. "
28+ "Failed to unescape a character due to an invalid escape sequence"
2729 ) ,
2830 }
2931 }
@@ -88,7 +90,7 @@ fn unescape_next_fragment(
8890/// #[serde(borrow)]
8991/// description: serde_json_core::str::EscapedStr<'a>,
9092/// }
91- ///
93+ ///
9294/// serde_json_core::de::from_str_escaped::<Event<'_>>(
9395/// r#"{ "name": "Party\u0021", "description": "I'm throwing a party! Hopefully the \u2600 shines!" }"#,
9496/// &mut [0; 8],
@@ -97,6 +99,7 @@ fn unescape_next_fragment(
9799/// ```
98100#[ derive( Debug , Clone , Copy , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
99101#[ serde( rename = "__serde_json_core_escaped_string__" ) ]
102+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
100103pub struct EscapedStr < ' a > ( pub & ' a str ) ;
101104
102105impl < ' a > EscapedStr < ' a > {
0 commit comments