From 1f93984dbe5e8a670ac2ff112e8a7a2b6667b16f Mon Sep 17 00:00:00 2001 From: b1ek Date: Sat, 16 Nov 2024 21:20:22 +1000 Subject: [PATCH] fix serde not compiling for struct with lifetime --- src/compiling/lexing/lexer.rs | 4 ++-- src/compiling/lexing/reader.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiling/lexing/lexer.rs b/src/compiling/lexing/lexer.rs index 8836ef9..6a9dbc8 100644 --- a/src/compiling/lexing/lexer.rs +++ b/src/compiling/lexing/lexer.rs @@ -33,13 +33,13 @@ pub struct Lexer { } #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -struct LexState<'a> { +struct LexState { word: String, is_indenting: bool, is_escaped: bool, token_start_index: usize, position: (usize, usize), - reader: Reader<'a>, + reader: Reader, lexem: Vec, region_handler: RegionHandler, compound_handler: CompoundHandler, diff --git a/src/compiling/lexing/reader.rs b/src/compiling/lexing/reader.rs index 438fae9..63085f8 100644 --- a/src/compiling/lexing/reader.rs +++ b/src/compiling/lexing/reader.rs @@ -10,18 +10,18 @@ pub enum ReadMode { } #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct Reader<'a> { - pub code: &'a String, +pub struct Reader { + pub code: String, pub row: usize, pub col: usize, pub index: usize, pub new_line: bool } -impl<'a> Reader<'a> { - pub fn new(code: &'a String) -> Self { +impl Reader { + pub fn new(code: &String) -> Self { Reader { - code, + code: code.clone(), row: BEGINNING.0, col: BEGINNING.1, index: 0, @@ -116,7 +116,7 @@ impl<'a> Reader<'a> { } } -impl<'a> Iterator for Reader<'a> { +impl Iterator for Reader { type Item = char; fn next(&mut self) -> Option {