Use array_iterator() over deprecated initalizer #42

Merged
bazaah merged 1 commits from feature/event/parser/use-into-iter into master 2022-03-26 15:49:51 +00:00
1 changed files with 20 additions and 3 deletions

View File

@ -253,7 +253,7 @@ impl Parser
// Retrieve any directives for the current document, merged
// with the defaults
let (start, end, directives) =
scan_document_directives(tokens, ArrayIter::new(DEFAULT_TAGS))?;
scan_document_directives(tokens, array_iterator(DEFAULT_TAGS))?;
let Directives { version, tags } = directives;
event =
@ -268,7 +268,7 @@ impl Parser
// Retrieve any directives for the current document, merged
// with the defaults
let (start, _, directives) =
scan_document_directives(tokens, ArrayIter::new(DEFAULT_TAGS))?;
scan_document_directives(tokens, array_iterator(DEFAULT_TAGS))?;
// Ensure we have an explicit DocumentStart indicator
let end = match peek!(~tokens)?
@ -289,7 +289,7 @@ impl Parser
else if first
{
let (start, end, directives) =
scan_document_directives(tokens, ArrayIter::new(DEFAULT_TAGS))?;
scan_document_directives(tokens, array_iterator(DEFAULT_TAGS))?;
let Directives { version, tags } = directives;
event =
@ -1301,6 +1301,23 @@ 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)]