2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2017-11-16 23:30:08 -08:00
|
|
|
|
2021-06-08 01:01:27 -07:00
|
|
|
#[derive(PartialEq, Debug, Clone)]
|
2019-11-07 10:55:15 -08:00
|
|
|
pub(crate) struct StringLiteral<'src> {
|
2021-09-16 06:44:40 -07:00
|
|
|
pub(crate) kind: StringKind,
|
|
|
|
pub(crate) raw: &'src str,
|
2021-04-05 21:28:37 -07:00
|
|
|
pub(crate) cooked: String,
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
|
2019-11-07 10:55:15 -08:00
|
|
|
impl Display for StringLiteral<'_> {
|
2019-04-11 23:58:08 -07:00
|
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
2021-04-05 21:28:37 -07:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"{}{}{}",
|
|
|
|
self.kind.delimiter(),
|
|
|
|
self.raw,
|
|
|
|
self.kind.delimiter()
|
|
|
|
)
|
2019-04-11 23:58:08 -07:00
|
|
|
}
|
|
|
|
}
|
2021-11-17 00:07:48 -08:00
|
|
|
|
|
|
|
impl<'src> Serialize for StringLiteral<'src> {
|
|
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
|
where
|
|
|
|
S: Serializer,
|
|
|
|
{
|
|
|
|
serializer.serialize_str(&self.cooked)
|
|
|
|
}
|
|
|
|
}
|