2019-04-11 15:23:14 -07:00
|
|
|
use crate::common::*;
|
2017-11-16 23:30:08 -08:00
|
|
|
|
|
|
|
#[derive(PartialEq, Debug)]
|
2019-11-07 10:55:15 -08:00
|
|
|
pub(crate) struct StringLiteral<'src> {
|
|
|
|
pub(crate) raw: &'src str,
|
|
|
|
pub(crate) cooked: Cow<'src, str>,
|
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 {
|
|
|
|
match self.cooked {
|
|
|
|
Cow::Borrowed(raw) => write!(f, "'{}'", raw),
|
|
|
|
Cow::Owned(_) => write!(f, "\"{}\"", self.raw),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|