lib: derive Clone for Parser

should now be safe to do
This commit is contained in:
Noah Hellman 2023-03-19 15:32:46 +01:00
parent 3a1a3996e9
commit 8382fe122f
2 changed files with 9 additions and 1 deletions

View file

@ -73,6 +73,7 @@ pub struct Event {
pub span: Span,
}
#[derive(Clone)]
pub struct Input<'s> {
/// Lexer, hosting source.
lexer: lex::Lexer<'s>,
@ -175,13 +176,15 @@ impl<'s> Input<'s> {
}
}
pub struct VerbatimState {
#[derive(Clone)]
struct VerbatimState {
event_opener: usize,
len_opener: u8,
non_whitespace_encountered: bool,
non_whitespace_last: Option<(lex::Kind, usize)>,
}
#[derive(Clone)]
pub struct Parser<'s> {
input: Input<'s>,
/// Stack with kind and index of _potential_ openers for containers.

View file

@ -577,6 +577,9 @@ type Set<T> = std::collections::BTreeSet<T>;
/// structure that will be kept for the duration of the parser's lifetime. Then, when the iterator
/// is advanced, the parser will start from the beginning of the document and parse inline elements
/// and emit [`Event`]s.
///
/// It is possible to clone the parser to e.g. avoid performing the block parsing multiple times.
#[derive(Clone)]
pub struct Parser<'s> {
src: &'s str,
@ -608,6 +611,7 @@ pub struct Parser<'s> {
inline_parser: inline::Parser<'s>,
}
#[derive(Clone)]
struct Heading {
/// Location of heading in src.
location: usize,
@ -618,6 +622,7 @@ struct Heading {
}
/// Because of potential future references, an initial pass is required to obtain all definitions.
#[derive(Clone)]
struct PrePass<'s> {
/// Link definitions and their attributes.
link_definitions: Map<&'s str, (CowStr<'s>, attr::Attributes<'s>)>,