Expose iter::ByRefSized as unstable feature and use it

This commit is contained in:
Paolo Barbolini 2022-06-12 00:55:09 +02:00
parent bc3fae4dc1
commit ce3b6f505e
5 changed files with 12 additions and 4 deletions

View File

@ -1,6 +1,6 @@
use crate::alloc::Allocator; use crate::alloc::Allocator;
use crate::vec; use crate::vec;
use core::iter::TrustedLen; use core::iter::{ByRefSized, TrustedLen};
use core::slice; use core::slice;
use super::VecDeque; use super::VecDeque;

View File

@ -143,6 +143,7 @@
#![feature(unchecked_math)] #![feature(unchecked_math)]
#![feature(unicode_internals)] #![feature(unicode_internals)]
#![feature(unsize)] #![feature(unsize)]
#![feature(std_internals)]
// //
// Language features: // Language features:
#![feature(allocator_internals)] #![feature(allocator_internals)]

View File

@ -4,8 +4,11 @@ use crate::ops::Try;
/// ///
/// Ideally this will no longer be required, eventually, but as can be seen in /// Ideally this will no longer be required, eventually, but as can be seen in
/// the benchmarks (as of Feb 2022 at least) `by_ref` can have performance cost. /// the benchmarks (as of Feb 2022 at least) `by_ref` can have performance cost.
pub(crate) struct ByRefSized<'a, I>(pub &'a mut I); #[unstable(feature = "std_internals", issue = "none")]
#[derive(Debug)]
pub struct ByRefSized<'a, I>(pub &'a mut I);
#[unstable(feature = "std_internals", issue = "none")]
impl<I: Iterator> Iterator for ByRefSized<'_, I> { impl<I: Iterator> Iterator for ByRefSized<'_, I> {
type Item = I::Item; type Item = I::Item;
@ -47,6 +50,7 @@ impl<I: Iterator> Iterator for ByRefSized<'_, I> {
} }
} }
#[unstable(feature = "std_internals", issue = "none")]
impl<I: DoubleEndedIterator> DoubleEndedIterator for ByRefSized<'_, I> { impl<I: DoubleEndedIterator> DoubleEndedIterator for ByRefSized<'_, I> {
#[inline] #[inline]
fn next_back(&mut self) -> Option<Self::Item> { fn next_back(&mut self) -> Option<Self::Item> {

View File

@ -32,7 +32,8 @@ pub use self::{
scan::Scan, skip::Skip, skip_while::SkipWhile, take::Take, take_while::TakeWhile, zip::Zip, scan::Scan, skip::Skip, skip_while::SkipWhile, take::Take, take_while::TakeWhile, zip::Zip,
}; };
pub(crate) use self::by_ref_sized::ByRefSized; #[unstable(feature = "std_internals", issue = "none")]
pub use self::by_ref_sized::ByRefSized;
#[stable(feature = "iter_cloned", since = "1.1.0")] #[stable(feature = "iter_cloned", since = "1.1.0")]
pub use self::cloned::Cloned; pub use self::cloned::Cloned;

View File

@ -398,6 +398,8 @@ pub use self::traits::{
#[stable(feature = "iter_zip", since = "1.59.0")] #[stable(feature = "iter_zip", since = "1.59.0")]
pub use self::adapters::zip; pub use self::adapters::zip;
#[unstable(feature = "std_internals", issue = "none")]
pub use self::adapters::ByRefSized;
#[stable(feature = "iter_cloned", since = "1.1.0")] #[stable(feature = "iter_cloned", since = "1.1.0")]
pub use self::adapters::Cloned; pub use self::adapters::Cloned;
#[stable(feature = "iter_copied", since = "1.36.0")] #[stable(feature = "iter_copied", since = "1.36.0")]
@ -422,7 +424,7 @@ pub use self::adapters::{
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
pub use self::adapters::{Intersperse, IntersperseWith}; pub use self::adapters::{Intersperse, IntersperseWith};
pub(crate) use self::adapters::{try_process, ByRefSized}; pub(crate) use self::adapters::try_process;
mod adapters; mod adapters;
mod range; mod range;