From dec0a0e154786563cfcf2e19c6ecedcb7267d2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Tue, 21 Jan 2025 20:26:18 +0200 Subject: [PATCH] Change tokens to use &str w/lifetime instead of String --- src/compiler/token.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/token.rs b/src/compiler/token.rs index 9d47abe..e5d6fac 100644 --- a/src/compiler/token.rs +++ b/src/compiler/token.rs @@ -45,16 +45,16 @@ impl TokenType { } #[derive(Debug, PartialEq)] -pub struct Token { - text: String, +pub struct Token<'source> { + text: &'source str, token_type: TokenType, loc: CodeLocation, } -impl Token { - pub fn new(text: &str, token_type: TokenType, loc: CodeLocation) -> Self { +impl<'source> Token<'source> { + pub fn new(text: &'source str, token_type: TokenType, loc: CodeLocation) -> Self { Self { - text: text.to_string(), + text, token_type, loc, }