Document TemplateElementValue better (#473)

Co-authored-by: Boshen <boshenc@gmail.com>
This commit is contained in:
u9g 2023-06-24 10:08:53 -04:00 committed by GitHub
parent 3656802fd4
commit 218683fa95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -407,10 +407,19 @@ pub struct TemplateElement {
pub value: TemplateElementValue,
}
/// See [template-strings-cooked-vs-raw](https://exploringjs.com/impatient-js/ch_template-literals.html#template-strings-cooked-vs-raw)
/// for more info
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct TemplateElementValue {
/// A raw interpretation where backslashes do not have special meaning.
/// For example, \t produces two characters a backslash and a t.
/// This interpretation of the template strings is stored in property .raw of the first argument (an Array).
pub raw: Atom,
/// A cooked interpretation where backslashes have special meaning.
/// For example, \t produces a tab character.
/// This interpretation of the template strings is stored as an Array in the first argument.
/// cooked = None when template literal has invalid escape sequence
pub cooked: Option<Atom>,
}