From 4031ed9d1f038329d271bcc0e94ec29171835bcb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:47:58 +0100 Subject: [PATCH] Store str instead of String in ParseError --- src/ast/parse.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ast/parse.rs b/src/ast/parse.rs index 76c768f6..bce820e3 100644 --- a/src/ast/parse.rs +++ b/src/ast/parse.rs @@ -189,7 +189,7 @@ fn ident(ctx: &Context) -> Res { } } -fn text(s: &str) -> impl Parser<()> + '_ { +fn text(s: &'static str) -> impl Parser<()> { move |ctx| { let mut span = ctx.span(); span.2 = (span.1 + s.len()).min(ctx.source.contents.len()); @@ -200,7 +200,7 @@ fn text(s: &str) -> impl Parser<()> + '_ { next.advance_past_whitespace(); Ok(((), span, next)) } else { - Err(ParseError::Text(span, s.to_string())) + Err(ParseError::Text(span, s)) } } } @@ -280,7 +280,7 @@ fn option(parser: impl Parser) -> impl Parser> { fn parens(f: impl Parser) -> impl Parser { choice( sequence3(text("["), f.clone(), text("]")), - sequence3(text("("), f.clone(), text(")")), + sequence3(text("("), f, text(")")), ) .map(|((), x, ()), _| x) } @@ -791,7 +791,7 @@ fn string(ctx: &Context) -> Res { #[derive(Debug, Error)] pub enum ParseError { #[error("{0}\nexpected \"{1}\"")] - Text(Span, String), + Text(Span, &'static str), #[error("{0}\nexpected string")] String(Span), #[error("{0}\nmissing end quote for string")]