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, pub span: Span,
} }
#[derive(Clone)]
pub struct Input<'s> { pub struct Input<'s> {
/// Lexer, hosting source. /// Lexer, hosting source.
lexer: lex::Lexer<'s>, lexer: lex::Lexer<'s>,
@ -175,13 +176,15 @@ impl<'s> Input<'s> {
} }
} }
pub struct VerbatimState { #[derive(Clone)]
struct VerbatimState {
event_opener: usize, event_opener: usize,
len_opener: u8, len_opener: u8,
non_whitespace_encountered: bool, non_whitespace_encountered: bool,
non_whitespace_last: Option<(lex::Kind, usize)>, non_whitespace_last: Option<(lex::Kind, usize)>,
} }
#[derive(Clone)]
pub struct Parser<'s> { pub struct Parser<'s> {
input: Input<'s>, input: Input<'s>,
/// Stack with kind and index of _potential_ openers for containers. /// 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 /// 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 /// is advanced, the parser will start from the beginning of the document and parse inline elements
/// and emit [`Event`]s. /// 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> { pub struct Parser<'s> {
src: &'s str, src: &'s str,
@ -608,6 +611,7 @@ pub struct Parser<'s> {
inline_parser: inline::Parser<'s>, inline_parser: inline::Parser<'s>,
} }
#[derive(Clone)]
struct Heading { struct Heading {
/// Location of heading in src. /// Location of heading in src.
location: usize, location: usize,
@ -618,6 +622,7 @@ struct Heading {
} }
/// Because of potential future references, an initial pass is required to obtain all definitions. /// Because of potential future references, an initial pass is required to obtain all definitions.
#[derive(Clone)]
struct PrePass<'s> { struct PrePass<'s> {
/// Link definitions and their attributes. /// Link definitions and their attributes.
link_definitions: Map<&'s str, (CowStr<'s>, attr::Attributes<'s>)>, link_definitions: Map<&'s str, (CowStr<'s>, attr::Attributes<'s>)>,