From 55858d15d93ea2abf88e6f5ea53183879f0a19e1 Mon Sep 17 00:00:00 2001 From: Ethiraric Date: Thu, 17 Oct 2024 19:17:26 +0200 Subject: [PATCH] Add `Parser::new_from_iter`. --- parser/src/parser.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/parser/src/parser.rs b/parser/src/parser.rs index aebf3d5..cf452da 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -7,7 +7,7 @@ use crate::{ input::{str::StrInput, Input}, scanner::{ScanError, Scanner, Span, TScalarStyle, Token, TokenType}, - Marker, + BufferedInput, Marker, }; use std::collections::HashMap; @@ -244,6 +244,17 @@ impl<'a> Parser> { } } +impl Parser> +where + T: Iterator, +{ + /// Create a new instance of a parser from an iterator of `char`s. + #[must_use] + pub fn new_from_iter(iter: T) -> Self { + Parser::new(BufferedInput::new(iter)) + } +} + impl Parser { /// Create a new instance of a parser from the given input of characters. pub fn new(src: T) -> Parser {