Simplify creating Lit

This commit is contained in:
Joscha 2022-11-22 16:29:31 +01:00
parent fafc567447
commit 45caafdc38
8 changed files with 38 additions and 14 deletions

View file

@ -53,6 +53,12 @@ impl HasSpan for NumLit {
}
}
impl NumLit {
pub fn lit(self) -> Lit {
Lit::Num(self)
}
}
#[derive(Clone)]
pub enum StringLitElem {
/// Normal unescaped characters
@ -100,6 +106,10 @@ impl StringLit {
span: ident.span,
}
}
pub fn lit(self) -> Lit {
Lit::String(self)
}
}
impl HasSpan for StringLit {
@ -144,6 +154,12 @@ impl HasSpan for TableLit {
}
}
impl TableLit {
pub fn lit(self) -> Lit {
Lit::Table(self)
}
}
#[derive(Clone)]
pub enum Lit {
/// `nil`