Use array_iterator in event/parser
tests macros #44
|
@ -34,14 +34,13 @@
|
|||
//!
|
||||
//! [`Token`]: enum@crate::token::Token
|
||||
|
||||
use std::array::IntoIter as ArrayIter;
|
||||
|
||||
use crate::{
|
||||
event::{
|
||||
error::{ParseError as Error, ParseResult as Result},
|
||||
state::{Flags, State, StateMachine, O_EMPTY, O_FIRST, O_IMPLICIT, O_NIL},
|
||||
types::{
|
||||
self, Directives, Event, EventData, NodeKind, TagDirectives, DEFAULT_TAGS, EMPTY_SCALAR,
|
||||
self, array_iterator, Directives, Event, EventData, NodeKind, TagDirectives,
|
||||
DEFAULT_TAGS, EMPTY_SCALAR,
|
||||
},
|
||||
},
|
||||
reader::{PeekReader, Read},
|
||||
|
@ -1301,23 +1300,6 @@ fn tags_to_owned<'a>((handle, prefix): (&Slice<'a>, &Slice<'a>))
|
|||
(handle.into(), prefix.into())
|
||||
}
|
||||
|
||||
/// Wrapper around IntoIterator::into_iter that works around
|
||||
/// the hack in `std` which makes our Rust edition's
|
||||
/// ARRAY.into_iter() postfix call take the array by
|
||||
/// reference.
|
||||
///
|
||||
/// It appears that ArrayIter::new() has been deprecated in
|
||||
/// a future rust version (1.59), so this should quiet those
|
||||
/// errors, when building against stable.
|
||||
///
|
||||
/// If/when we bump the crate's MSRV to >= 1.59 we can
|
||||
/// remove this function and call the postfix .into_iter()
|
||||
/// method directly.
|
||||
fn array_iterator<T, const N: usize>(arr: [T; N]) -> ArrayIter<T, N>
|
||||
{
|
||||
IntoIterator::into_iter(arr)
|
||||
}
|
||||
|
||||
/// Provides an [`Iterator`] interface to interact with
|
||||
/// [`Event`]s through.
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -68,7 +68,7 @@ macro_rules! event {
|
|||
types::DEFAULT_VERSION
|
||||
),
|
||||
tags: std::iter::FromIterator::from_iter(
|
||||
std::array::IntoIter::new(types::DEFAULT_TAGS).chain(vec![
|
||||
types::array_iterator(types::DEFAULT_TAGS).chain(vec![
|
||||
$($( ($crate::token::Slice::from($handle), $crate::token::Slice::from($prefix)) ),*)?
|
||||
])),
|
||||
},
|
||||
|
|
|
@ -419,7 +419,7 @@ impl Default for Directives<'_>
|
|||
{
|
||||
Self {
|
||||
version: DEFAULT_VERSION,
|
||||
tags: ArrayIter::new(DEFAULT_TAGS).collect(),
|
||||
tags: array_iterator(DEFAULT_TAGS).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -453,3 +453,20 @@ pub enum ScalarStyle
|
|||
Literal,
|
||||
Folded,
|
||||
}
|
||||
|
||||
/// Wrapper around IntoIterator::into_iter that works around
|
||||
/// the hack in `std` which makes our Rust edition's
|
||||
/// ARRAY.into_iter() postfix call take the array by
|
||||
/// reference.
|
||||
///
|
||||
/// It appears that ArrayIter::new() has been deprecated in
|
||||
/// a future rust version (1.59), so this should quiet those
|
||||
/// errors, when building against stable.
|
||||
///
|
||||
/// If/when we bump the crate's MSRV to >= 1.59 we can
|
||||
/// remove this function and call the postfix .into_iter()
|
||||
/// method directly.
|
||||
pub(in crate::event) fn array_iterator<T, const N: usize>(arr: [T; N]) -> ArrayIter<T, N>
|
||||
{
|
||||
IntoIterator::into_iter(arr)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue