Add Parser::new_from_iter
.
This commit is contained in:
parent
53dc2b9aba
commit
55858d15d9
1 changed files with 12 additions and 1 deletions
|
@ -7,7 +7,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
input::{str::StrInput, Input},
|
input::{str::StrInput, Input},
|
||||||
scanner::{ScanError, Scanner, Span, TScalarStyle, Token, TokenType},
|
scanner::{ScanError, Scanner, Span, TScalarStyle, Token, TokenType},
|
||||||
Marker,
|
BufferedInput, Marker,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -244,6 +244,17 @@ impl<'a> Parser<StrInput<'a>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Parser<BufferedInput<T>>
|
||||||
|
where
|
||||||
|
T: Iterator<Item = char>,
|
||||||
|
{
|
||||||
|
/// 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<T: Input> Parser<T> {
|
impl<T: Input> Parser<T> {
|
||||||
/// Create a new instance of a parser from the given input of characters.
|
/// Create a new instance of a parser from the given input of characters.
|
||||||
pub fn new(src: T) -> Parser<T> {
|
pub fn new(src: T) -> Parser<T> {
|
||||||
|
|
Loading…
Reference in a new issue