tamer: Use TokenStream trait alias where applicable
Simple replacement to improve readability.main
parent
7e6cb2c948
commit
a9fd1c7557
|
@ -25,7 +25,7 @@
|
|||
//! - [`elem_wrap`] wraps a token stream iterator as the body of an
|
||||
//! element of the given name.
|
||||
|
||||
use super::{QName, Token};
|
||||
use super::{QName, Token, TokenStream};
|
||||
use crate::span::Span;
|
||||
use std::iter::{once, Chain, Once};
|
||||
|
||||
|
@ -42,7 +42,7 @@ use std::iter::{once, Chain, Once};
|
|||
pub fn elem_wrap<S, I>(name: QName, span: S, inner: I) -> ElemWrapIter<I>
|
||||
where
|
||||
S: Into<(Span, Span)>,
|
||||
I: Iterator<Item = Token>,
|
||||
I: TokenStream,
|
||||
{
|
||||
let twospan: (Span, Span) = span.into();
|
||||
|
||||
|
@ -59,18 +59,18 @@ where
|
|||
/// iterator.
|
||||
///
|
||||
/// See [`elem_wrap`] to construct this iterator.
|
||||
pub struct ElemWrapIter<I: Iterator<Item = Token>>(
|
||||
pub struct ElemWrapIter<I: TokenStream>(
|
||||
Chain<Chain<Once<Token>, I>, Once<Token>>,
|
||||
);
|
||||
|
||||
impl<I: Iterator<Item = Token>> ElemWrapIter<I> {
|
||||
impl<I: TokenStream> ElemWrapIter<I> {
|
||||
#[inline]
|
||||
fn new(open: Token, inner: I, close: Token) -> Self {
|
||||
Self(once(open).chain(inner).chain(once(close)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Iterator<Item = Token>> Iterator for ElemWrapIter<I> {
|
||||
impl<I: TokenStream> Iterator for ElemWrapIter<I> {
|
||||
type Item = Token;
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -191,7 +191,7 @@
|
|||
//! For more information,
|
||||
//! see [`AttrParts`].
|
||||
|
||||
use super::{AttrValue, QName, Text, Token, TokenResultStream};
|
||||
use super::{AttrValue, QName, Text, Token, TokenResultStream, TokenStream};
|
||||
use crate::span::Span;
|
||||
use std::{fmt::Display, mem::take};
|
||||
|
||||
|
@ -849,7 +849,7 @@ pub fn parse(state: &mut ParserState, tok: Token) -> Option<Result<Parsed>> {
|
|||
/// let parser = parser_from(token_stream);
|
||||
/// ```
|
||||
pub fn parser_from(
|
||||
toks: impl Iterator<Item = Token>,
|
||||
toks: impl TokenStream,
|
||||
) -> impl Iterator<Item = Result<Tree>> {
|
||||
toks.scan(ParserState::new(), parse)
|
||||
.filter_map(|parsed| match parsed {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
//! Lower XIR stream into an XML byte stream via [`Write`].
|
||||
|
||||
use super::{Error as XirError, QName, Token};
|
||||
use super::{Error as XirError, QName, Token, TokenStream};
|
||||
use crate::ir::xir::{AttrValue, Text};
|
||||
use crate::sym::GlobalSymbolResolve;
|
||||
use std::io::{Error as IoError, Write};
|
||||
|
@ -318,7 +318,7 @@ impl XmlWriter for Token {
|
|||
}
|
||||
}
|
||||
|
||||
impl<I: Iterator<Item = Token>> XmlWriter for I {
|
||||
impl<I: TokenStream> XmlWriter for I {
|
||||
fn write<W: Write>(
|
||||
mut self,
|
||||
sink: &mut W,
|
||||
|
|
Loading…
Reference in New Issue