Token lookahead message is always a string literal
diff --git a/src/lookahead.rs b/src/lookahead.rs
index 15e0346..4a97caa 100644
--- a/src/lookahead.rs
+++ b/src/lookahead.rs
@@ -64,7 +64,7 @@
pub struct Lookahead1<'a> {
scope: Span,
cursor: Cursor<'a>,
- comparisons: RefCell<Vec<String>>,
+ comparisons: RefCell<Vec<&'static str>>,
}
pub fn new(scope: Span, cursor: Cursor) -> Lookahead1 {
diff --git a/src/token.rs b/src/token.rs
index 68f9475..2bfbd0f 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -132,7 +132,7 @@
// Not public API.
#[doc(hidden)]
- fn display() -> String;
+ fn display() -> &'static str;
}
#[cfg(feature = "parsing")]
@@ -153,8 +153,8 @@
.is_ok()
}
- fn display() -> String {
- $display.to_owned()
+ fn display() -> &'static str {
+ $display
}
}
@@ -428,8 +428,8 @@
lookahead::is_delimiter(cursor, Delimiter::Parenthesis)
}
- fn display() -> String {
- "parentheses".to_owned()
+ fn display() -> &'static str {
+ "parentheses"
}
}
@@ -439,8 +439,8 @@
lookahead::is_delimiter(cursor, Delimiter::Brace)
}
- fn display() -> String {
- "curly braces".to_owned()
+ fn display() -> &'static str {
+ "curly braces"
}
}
@@ -450,8 +450,8 @@
lookahead::is_delimiter(cursor, Delimiter::Bracket)
}
- fn display() -> String {
- "square brackets".to_owned()
+ fn display() -> &'static str {
+ "square brackets"
}
}
@@ -461,8 +461,8 @@
lookahead::is_delimiter(cursor, Delimiter::None)
}
- fn display() -> String {
- "invisible group".to_owned()
+ fn display() -> &'static str {
+ "invisible group"
}
}