Store bool for BoolLit instead of str

This commit is contained in:
Guillaume Gomez 2024-07-26 22:05:19 +02:00
parent bb77b1ea41
commit eb4ceae2a3
2 changed files with 9 additions and 5 deletions

View File

@ -1888,8 +1888,12 @@ impl<'a> Generator<'a> {
DisplayWrap::Wrapped
}
fn visit_bool_lit(&mut self, buf: &mut Buffer, s: &str) -> DisplayWrap {
buf.write(s);
fn visit_bool_lit(&mut self, buf: &mut Buffer, s: bool) -> DisplayWrap {
if s {
buf.write("true");
} else {
buf.write("false");
}
DisplayWrap::Unwrapped
}

View File

@ -35,7 +35,7 @@ macro_rules! expr_prec_layer {
#[derive(Clone, Debug, PartialEq)]
pub enum Expr<'a> {
BoolLit(&'a str),
BoolLit(bool),
NumLit(&'a str),
StrLit(&'a str),
CharLit(&'a str),
@ -334,8 +334,8 @@ impl<'a> Expr<'a> {
let start = i;
map(path_or_identifier, |v| match v {
PathOrIdentifier::Path(v) => Self::Path(v),
PathOrIdentifier::Identifier(v @ "true") => Self::BoolLit(v),
PathOrIdentifier::Identifier(v @ "false") => Self::BoolLit(v),
PathOrIdentifier::Identifier("true") => Self::BoolLit(true),
PathOrIdentifier::Identifier("false") => Self::BoolLit(false),
PathOrIdentifier::Identifier(v) => Self::Var(v),
})(i)
.map(|(i, expr)| (i, WithSpan::new(expr, start)))