diff options
-rw-r--r-- | src/parser.rs | 8 | ||||
-rw-r--r-- | src/tokenizer.rs | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/parser.rs b/src/parser.rs index 3361baf..1e689ee 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -10,8 +10,8 @@ use crate::{Constructs, Options}; /// Importantly, this contains a set of known definitions. /// It also references the input value as [`Code`][]s. #[derive(Debug)] -pub struct ParseState { - pub constructs: Constructs, +pub struct ParseState<'a> { + pub constructs: &'a Constructs, /// List of codes. pub codes: Vec<Code>, /// Set of defined identifiers. @@ -21,9 +21,9 @@ pub struct ParseState { /// Turn a string of markdown into events. /// /// Passes the codes back so the compiler can access the source. -pub fn parse(value: &str, options: &Options) -> (Vec<Event>, ParseState) { +pub fn parse<'a>(value: &str, options: &'a Options) -> (Vec<Event>, ParseState<'a>) { let mut parse_state = ParseState { - constructs: options.constructs.clone(), + constructs: &options.constructs, codes: parse_codes(value), definitions: vec![], }; diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 4e184f4..8813bdc 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -203,7 +203,7 @@ pub struct Tokenizer<'a> { /// List of names associated with attached resolvers. resolver_ids: Vec<String>, /// Shared parsing state across tokenizers. - pub parse_state: &'a ParseState, + pub parse_state: &'a ParseState<'a>, /// Stack of label (start) that could form images and links. /// /// Used when tokenizing [text content][crate::content::text]. @@ -235,7 +235,7 @@ pub struct Tokenizer<'a> { impl<'a> Tokenizer<'a> { /// Create a new tokenizer. - pub fn new(point: Point, index: usize, parse_state: &'a ParseState) -> Tokenizer { + pub fn new(point: Point, index: usize, parse_state: &'a ParseState) -> Tokenizer<'a> { Tokenizer { previous: Code::None, current: Code::None, @@ -701,7 +701,6 @@ fn feed_impl( codes: &[Code], start: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, ) -> StateFnResult { - let codes = codes; let mut state = State::Fn(Box::new(start)); let mut index = 0; |