2
2
3
3
use core:: fmt;
4
4
5
- #[ derive( Debug ) ]
6
5
/// A fragment of an escaped string
6
+ #[ derive( Debug ) ]
7
+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
7
8
pub enum EscapedStringFragment < ' a > {
8
9
/// A series of characters which weren't escaped in the input.
9
10
NotEscaped ( & ' a str ) ,
10
11
/// A character which was escaped in the input.
11
12
Escaped ( char ) ,
12
13
}
13
14
14
- #[ derive( Debug ) ]
15
15
/// Errors occuring while unescaping strings.
16
+ #[ derive( Debug ) ]
17
+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
16
18
pub enum StringUnescapeError {
17
19
/// Failed to unescape a character due to an invalid escape sequence.
18
20
InvalidEscapeSequence ,
@@ -23,7 +25,7 @@ impl fmt::Display for StringUnescapeError {
23
25
match self {
24
26
StringUnescapeError :: InvalidEscapeSequence => write ! (
25
27
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"
27
29
) ,
28
30
}
29
31
}
@@ -88,7 +90,7 @@ fn unescape_next_fragment(
88
90
/// #[serde(borrow)]
89
91
/// description: serde_json_core::str::EscapedStr<'a>,
90
92
/// }
91
- ///
93
+ ///
92
94
/// serde_json_core::de::from_str_escaped::<Event<'_>>(
93
95
/// r#"{ "name": "Party\u0021", "description": "I'm throwing a party! Hopefully the \u2600 shines!" }"#,
94
96
/// &mut [0; 8],
@@ -97,6 +99,7 @@ fn unescape_next_fragment(
97
99
/// ```
98
100
#[ derive( Debug , Clone , Copy , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
99
101
#[ serde( rename = "__serde_json_core_escaped_string__" ) ]
102
+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
100
103
pub struct EscapedStr < ' a > ( pub & ' a str ) ;
101
104
102
105
impl < ' a > EscapedStr < ' a > {
0 commit comments