Bootstrapping preparation for the library
Since just `ops::Try` will need to change meaning.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess};
|
use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess};
|
||||||
use core::ops::Try;
|
use core::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
use super::{count, wrap_index, RingSlices};
|
use super::{count, wrap_index, RingSlices};
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
let (mut iter, final_res);
|
let (mut iter, final_res);
|
||||||
if self.tail <= self.head {
|
if self.tail <= self.head {
|
||||||
@@ -140,7 +140,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
let (mut iter, final_res);
|
let (mut iter, final_res);
|
||||||
if self.tail <= self.head {
|
if self.tail <= self.head {
|
||||||
|
|||||||
@@ -141,6 +141,7 @@
|
|||||||
#![feature(alloc_layout_extra)]
|
#![feature(alloc_layout_extra)]
|
||||||
#![feature(trusted_random_access)]
|
#![feature(trusted_random_access)]
|
||||||
#![feature(try_trait)]
|
#![feature(try_trait)]
|
||||||
|
#![feature(try_trait_transition)]
|
||||||
#![feature(min_type_alias_impl_trait)]
|
#![feature(min_type_alias_impl_trait)]
|
||||||
#![feature(associated_type_bounds)]
|
#![feature(associated_type_bounds)]
|
||||||
#![feature(slice_group_by)]
|
#![feature(slice_group_by)]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::iter::{DoubleEndedIterator, FusedIterator, Iterator, TrustedLen};
|
use crate::iter::{DoubleEndedIterator, FusedIterator, Iterator, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that links two iterators together, in a chain.
|
/// An iterator that links two iterators together, in a chain.
|
||||||
///
|
///
|
||||||
@@ -98,7 +98,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(Acc, Self::Item) -> R,
|
F: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
if let Some(ref mut a) = self.a {
|
if let Some(ref mut a) = self.a {
|
||||||
acc = a.try_fold(acc, &mut f)?;
|
acc = a.try_fold(acc, &mut f)?;
|
||||||
@@ -281,7 +281,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(Acc, Self::Item) -> R,
|
F: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
if let Some(ref mut b) = self.b {
|
if let Some(ref mut b) = self.b {
|
||||||
acc = b.try_rfold(acc, &mut f)?;
|
acc = b.try_rfold(acc, &mut f)?;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess};
|
use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess};
|
||||||
use crate::iter::{FusedIterator, TrustedLen};
|
use crate::iter::{FusedIterator, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that clones the elements of an underlying iterator.
|
/// An iterator that clones the elements of an underlying iterator.
|
||||||
///
|
///
|
||||||
@@ -46,7 +46,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
self.it.try_fold(init, clone_try_fold(f))
|
self.it.try_fold(init, clone_try_fold(f))
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
self.it.try_rfold(init, clone_try_fold(f))
|
self.it.try_rfold(init, clone_try_fold(f))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess};
|
use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess};
|
||||||
use crate::iter::{FusedIterator, TrustedLen};
|
use crate::iter::{FusedIterator, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that copies the elements of an underlying iterator.
|
/// An iterator that copies the elements of an underlying iterator.
|
||||||
///
|
///
|
||||||
@@ -50,7 +50,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
self.it.try_fold(init, copy_try_fold(f))
|
self.it.try_fold(init, copy_try_fold(f))
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
self.it.try_rfold(init, copy_try_fold(f))
|
self.it.try_rfold(init, copy_try_fold(f))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{iter::FusedIterator, ops::Try};
|
use crate::{iter::FusedIterator, ops::TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator that repeats endlessly.
|
/// An iterator that repeats endlessly.
|
||||||
///
|
///
|
||||||
@@ -53,7 +53,7 @@ where
|
|||||||
fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
|
fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnMut(Acc, Self::Item) -> R,
|
F: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
// fully iterate the current iterator. this is necessary because
|
// fully iterate the current iterator. this is necessary because
|
||||||
// `self.iter` may be empty even when `self.orig` isn't
|
// `self.iter` may be empty even when `self.orig` isn't
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::iter::adapters::{zip::try_get_unchecked, SourceIter, TrustedRandomAccess};
|
use crate::iter::adapters::{zip::try_get_unchecked, SourceIter, TrustedRandomAccess};
|
||||||
use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen};
|
use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that yields the current count and the element during iteration.
|
/// An iterator that yields the current count and the element during iteration.
|
||||||
///
|
///
|
||||||
@@ -71,7 +71,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn enumerate<'a, T, Acc, R>(
|
fn enumerate<'a, T, Acc, R>(
|
||||||
@@ -150,7 +150,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
// Can safely add and subtract the count, as `ExactSizeIterator` promises
|
// Can safely add and subtract the count, as `ExactSizeIterator` promises
|
||||||
// that the number of elements fits into a `usize`.
|
// that the number of elements fits into a `usize`.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that filters the elements of `iter` with `predicate`.
|
/// An iterator that filters the elements of `iter` with `predicate`.
|
||||||
///
|
///
|
||||||
@@ -37,7 +37,7 @@ fn filter_fold<T, Acc>(
|
|||||||
move |acc, item| if predicate(&item) { fold(acc, item) } else { acc }
|
move |acc, item| if predicate(&item) { fold(acc, item) } else { acc }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter_try_fold<'a, T, Acc, R: Try<Ok = Acc>>(
|
fn filter_try_fold<'a, T, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
predicate: &'a mut impl FnMut(&T) -> bool,
|
predicate: &'a mut impl FnMut(&T) -> bool,
|
||||||
mut fold: impl FnMut(Acc, T) -> R + 'a,
|
mut fold: impl FnMut(Acc, T) -> R + 'a,
|
||||||
) -> impl FnMut(Acc, T) -> R + 'a {
|
) -> impl FnMut(Acc, T) -> R + 'a {
|
||||||
@@ -88,7 +88,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_fold(init, filter_try_fold(&mut self.predicate, fold))
|
self.iter.try_fold(init, filter_try_fold(&mut self.predicate, fold))
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_rfold(init, filter_try_fold(&mut self.predicate, fold))
|
self.iter.try_rfold(init, filter_try_fold(&mut self.predicate, fold))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator that uses `f` to both filter and map elements from `iter`.
|
/// An iterator that uses `f` to both filter and map elements from `iter`.
|
||||||
///
|
///
|
||||||
@@ -39,7 +39,7 @@ fn filter_map_fold<T, B, Acc>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter_map_try_fold<'a, T, B, Acc, R: Try<Ok = Acc>>(
|
fn filter_map_try_fold<'a, T, B, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
f: &'a mut impl FnMut(T) -> Option<B>,
|
f: &'a mut impl FnMut(T) -> Option<B>,
|
||||||
mut fold: impl FnMut(Acc, B) -> R + 'a,
|
mut fold: impl FnMut(Acc, B) -> R + 'a,
|
||||||
) -> impl FnMut(Acc, T) -> R + 'a {
|
) -> impl FnMut(Acc, T) -> R + 'a {
|
||||||
@@ -72,7 +72,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_fold(init, filter_map_try_fold(&mut self.f, fold))
|
self.iter.try_fold(init, filter_map_try_fold(&mut self.f, fold))
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_rfold(init, filter_map_try_fold(&mut self.f, fold))
|
self.iter.try_rfold(init, filter_map_try_fold(&mut self.f, fold))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{DoubleEndedIterator, Fuse, FusedIterator, Iterator, Map};
|
use crate::iter::{DoubleEndedIterator, Fuse, FusedIterator, Iterator, Map};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that maps each element to an iterator, and yields the elements
|
/// An iterator that maps each element to an iterator, and yields the elements
|
||||||
/// of the produced iterators.
|
/// of the produced iterators.
|
||||||
@@ -61,7 +61,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.inner.try_fold(init, fold)
|
self.inner.try_fold(init, fold)
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.inner.try_rfold(init, fold)
|
self.inner.try_rfold(init, fold)
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.inner.try_fold(init, fold)
|
self.inner.try_fold(init, fold)
|
||||||
}
|
}
|
||||||
@@ -208,7 +208,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.inner.try_rfold(init, fold)
|
self.inner.try_rfold(init, fold)
|
||||||
}
|
}
|
||||||
@@ -293,10 +293,10 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn flatten<'a, T: IntoIterator, Acc, R: Try<Ok = Acc>>(
|
fn flatten<'a, T: IntoIterator, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
frontiter: &'a mut Option<T::IntoIter>,
|
frontiter: &'a mut Option<T::IntoIter>,
|
||||||
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
|
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
|
||||||
) -> impl FnMut(Acc, T) -> R + 'a {
|
) -> impl FnMut(Acc, T) -> R + 'a {
|
||||||
@@ -382,10 +382,10 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn flatten<'a, T: IntoIterator, Acc, R: Try<Ok = Acc>>(
|
fn flatten<'a, T: IntoIterator, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
backiter: &'a mut Option<T::IntoIter>,
|
backiter: &'a mut Option<T::IntoIter>,
|
||||||
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
|
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
|
||||||
) -> impl FnMut(Acc, T) -> R + 'a
|
) -> impl FnMut(Acc, T) -> R + 'a
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::iter::adapters::{zip::try_get_unchecked, InPlaceIterable, SourceIter}
|
|||||||
use crate::iter::{
|
use crate::iter::{
|
||||||
DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess,
|
DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess,
|
||||||
};
|
};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that yields `None` forever after the underlying iterator
|
/// An iterator that yields `None` forever after the underlying iterator
|
||||||
/// yields `None` once.
|
/// yields `None` once.
|
||||||
@@ -92,7 +92,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
FuseImpl::try_fold(self, acc, fold)
|
FuseImpl::try_fold(self, acc, fold)
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
FuseImpl::try_rfold(self, acc, fold)
|
FuseImpl::try_rfold(self, acc, fold)
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ trait FuseImpl<I> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>;
|
R: TryWhereOutputEquals<Acc>;
|
||||||
fn fold<Acc, Fold>(self, acc: Acc, fold: Fold) -> Acc
|
fn fold<Acc, Fold>(self, acc: Acc, fold: Fold) -> Acc
|
||||||
where
|
where
|
||||||
Fold: FnMut(Acc, Self::Item) -> Acc;
|
Fold: FnMut(Acc, Self::Item) -> Acc;
|
||||||
@@ -238,7 +238,7 @@ trait FuseImpl<I> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
I: DoubleEndedIterator;
|
I: DoubleEndedIterator;
|
||||||
fn rfold<Acc, Fold>(self, acc: Acc, fold: Fold) -> Acc
|
fn rfold<Acc, Fold>(self, acc: Acc, fold: Fold) -> Acc
|
||||||
where
|
where
|
||||||
@@ -305,7 +305,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
if let Some(ref mut iter) = self.iter {
|
if let Some(ref mut iter) = self.iter {
|
||||||
acc = iter.try_fold(acc, fold)?;
|
acc = iter.try_fold(acc, fold)?;
|
||||||
@@ -354,7 +354,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
I: DoubleEndedIterator,
|
I: DoubleEndedIterator,
|
||||||
{
|
{
|
||||||
if let Some(ref mut iter) = self.iter {
|
if let Some(ref mut iter) = self.iter {
|
||||||
@@ -443,7 +443,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
unchecked!(self).try_fold(init, fold)
|
unchecked!(self).try_fold(init, fold)
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
I: DoubleEndedIterator,
|
I: DoubleEndedIterator,
|
||||||
{
|
{
|
||||||
unchecked!(self).try_rfold(init, fold)
|
unchecked!(self).try_rfold(init, fold)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that calls a function with a reference to each element before
|
/// An iterator that calls a function with a reference to each element before
|
||||||
/// yielding it.
|
/// yielding it.
|
||||||
@@ -87,7 +87,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_fold(init, inspect_try_fold(&mut self.f, fold))
|
self.iter.try_fold(init, inspect_try_fold(&mut self.f, fold))
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_rfold(init, inspect_try_fold(&mut self.f, fold))
|
self.iter.try_rfold(init, inspect_try_fold(&mut self.f, fold))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::adapters::{zip::try_get_unchecked, SourceIter, TrustedRandomAccess};
|
use crate::iter::adapters::{zip::try_get_unchecked, SourceIter, TrustedRandomAccess};
|
||||||
use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen};
|
use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that maps the values of `iter` with `f`.
|
/// An iterator that maps the values of `iter` with `f`.
|
||||||
///
|
///
|
||||||
@@ -110,7 +110,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
G: FnMut(Acc, Self::Item) -> R,
|
G: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_fold(init, map_try_fold(&mut self.f, g))
|
self.iter.try_fold(init, map_try_fold(&mut self.f, g))
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
G: FnMut(Acc, Self::Item) -> R,
|
G: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.iter.try_rfold(init, map_try_fold(&mut self.f, g))
|
self.iter.try_rfold(init, map_try_fold(&mut self.f, g))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{adapters::SourceIter, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, InPlaceIterable};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator that only accepts elements while `predicate` returns `Some(_)`.
|
/// An iterator that only accepts elements while `predicate` returns `Some(_)`.
|
||||||
///
|
///
|
||||||
@@ -54,7 +54,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
let Self { iter, predicate } = self;
|
let Self { iter, predicate } = self;
|
||||||
iter.try_fold(init, |acc, x| match predicate(x) {
|
iter.try_fold(init, |acc, x| match predicate(x) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::iter::{InPlaceIterable, Iterator};
|
use crate::iter::{InPlaceIterable, Iterator};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
mod chain;
|
mod chain;
|
||||||
mod cloned;
|
mod cloned;
|
||||||
@@ -167,7 +167,7 @@ where
|
|||||||
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
let error = &mut *self.error;
|
let error = &mut *self.error;
|
||||||
self.iter
|
self.iter
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen};
|
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator with a `peek()` that returns an optional reference to the next
|
/// An iterator with a `peek()` that returns an optional reference to the next
|
||||||
/// element.
|
/// element.
|
||||||
@@ -91,7 +91,7 @@ impl<I: Iterator> Iterator for Peekable<I> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
let acc = match self.peeked.take() {
|
let acc = match self.peeked.take() {
|
||||||
Some(None) => return try { init },
|
Some(None) => return try { init },
|
||||||
@@ -134,7 +134,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
match self.peeked.take() {
|
match self.peeked.take() {
|
||||||
Some(None) => try { init },
|
Some(None) => try { init },
|
||||||
@@ -142,7 +142,7 @@ where
|
|||||||
Ok(acc) => f(acc, v),
|
Ok(acc) => f(acc, v),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.peeked = Some(Some(v));
|
self.peeked = Some(Some(v));
|
||||||
Try::from_error(e)
|
R::from_error(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => self.iter.try_rfold(init, f),
|
None => self.iter.try_rfold(init, f),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::iter::{FusedIterator, TrustedLen};
|
use crate::iter::{FusedIterator, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// A double-ended iterator with the direction inverted.
|
/// A double-ended iterator with the direction inverted.
|
||||||
///
|
///
|
||||||
@@ -51,7 +51,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
self.iter.try_rfold(init, f)
|
self.iter.try_rfold(init, f)
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
self.iter.try_fold(init, f)
|
self.iter.try_fold(init, f)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{adapters::SourceIter, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, InPlaceIterable};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator to maintain state while iterating another iterator.
|
/// An iterator to maintain state while iterating another iterator.
|
||||||
///
|
///
|
||||||
@@ -56,9 +56,9 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
fn scan<'a, T, St, B, Acc, R: Try<Ok = Acc>>(
|
fn scan<'a, T, St, B, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
state: &'a mut St,
|
state: &'a mut St,
|
||||||
f: &'a mut impl FnMut(&mut St, T) -> Option<B>,
|
f: &'a mut impl FnMut(&mut St, T) -> Option<B>,
|
||||||
mut fold: impl FnMut(Acc, B) -> R + 'a,
|
mut fold: impl FnMut(Acc, B) -> R + 'a,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::intrinsics::unlikely;
|
use crate::intrinsics::unlikely;
|
||||||
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator that skips over `n` elements of `iter`.
|
/// An iterator that skips over `n` elements of `iter`.
|
||||||
///
|
///
|
||||||
@@ -88,7 +88,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
let n = self.n;
|
let n = self.n;
|
||||||
self.n = 0;
|
self.n = 0;
|
||||||
@@ -146,9 +146,9 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
fn check<T, Acc, R: Try<Ok = Acc>>(
|
fn check<T, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
mut n: usize,
|
mut n: usize,
|
||||||
mut fold: impl FnMut(Acc, T) -> R,
|
mut fold: impl FnMut(Acc, T) -> R,
|
||||||
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> {
|
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
|
|
||||||
/// An iterator that rejects elements while `predicate` returns `true`.
|
/// An iterator that rejects elements while `predicate` returns `true`.
|
||||||
///
|
///
|
||||||
@@ -70,7 +70,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
if !self.flag {
|
if !self.flag {
|
||||||
match self.next() {
|
match self.next() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{intrinsics, iter::from_fn, ops::Try};
|
use crate::{intrinsics, iter::from_fn, ops::TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator for stepping iterators by a custom amount.
|
/// An iterator for stepping iterators by a custom amount.
|
||||||
///
|
///
|
||||||
@@ -111,7 +111,7 @@ where
|
|||||||
fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
|
fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnMut(Acc, Self::Item) -> R,
|
F: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn nth<I: Iterator>(iter: &mut I, step: usize) -> impl FnMut() -> Option<I::Item> + '_ {
|
fn nth<I: Iterator>(iter: &mut I, step: usize) -> impl FnMut() -> Option<I::Item> + '_ {
|
||||||
@@ -187,7 +187,7 @@ where
|
|||||||
fn try_rfold<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R
|
fn try_rfold<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnMut(Acc, Self::Item) -> R,
|
F: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn nth_back<I: DoubleEndedIterator>(
|
fn nth_back<I: DoubleEndedIterator>(
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::iter::{
|
|||||||
adapters::zip::try_get_unchecked, adapters::SourceIter, FusedIterator, InPlaceIterable,
|
adapters::zip::try_get_unchecked, adapters::SourceIter, FusedIterator, InPlaceIterable,
|
||||||
TrustedLen, TrustedRandomAccess,
|
TrustedLen, TrustedRandomAccess,
|
||||||
};
|
};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator that only iterates over the first `n` iterations of `iter`.
|
/// An iterator that only iterates over the first `n` iterations of `iter`.
|
||||||
///
|
///
|
||||||
@@ -80,9 +80,9 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
fn check<'a, T, Acc, R: Try<Ok = Acc>>(
|
fn check<'a, T, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
n: &'a mut usize,
|
n: &'a mut usize,
|
||||||
mut fold: impl FnMut(Acc, T) -> R + 'a,
|
mut fold: impl FnMut(Acc, T) -> R + 'a,
|
||||||
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> + 'a {
|
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> + 'a {
|
||||||
@@ -178,7 +178,7 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
if self.n == 0 {
|
if self.n == 0 {
|
||||||
try { init }
|
try { init }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator that only accepts elements while `predicate` returns `true`.
|
/// An iterator that only accepts elements while `predicate` returns `true`.
|
||||||
///
|
///
|
||||||
@@ -68,9 +68,9 @@ where
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
fn check<'a, T, Acc, R: Try<Ok = Acc>>(
|
fn check<'a, T, Acc, R: TryWhereOutputEquals<Acc>>(
|
||||||
flag: &'a mut bool,
|
flag: &'a mut bool,
|
||||||
p: &'a mut impl FnMut(&T) -> bool,
|
p: &'a mut impl FnMut(&T) -> bool,
|
||||||
mut fold: impl FnMut(Acc, T) -> R + 'a,
|
mut fold: impl FnMut(Acc, T) -> R + 'a,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::char;
|
use crate::char;
|
||||||
use crate::convert::TryFrom;
|
use crate::convert::TryFrom;
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::ops::{self, Try};
|
use crate::ops::{self, TryWhereOutputEquals};
|
||||||
|
|
||||||
use super::{FusedIterator, TrustedLen, TrustedRandomAccess};
|
use super::{FusedIterator, TrustedLen, TrustedRandomAccess};
|
||||||
|
|
||||||
@@ -755,7 +755,7 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
if self.is_empty() {
|
if self.is_empty() {
|
||||||
return try { init };
|
return try { init };
|
||||||
@@ -860,7 +860,7 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
if self.is_empty() {
|
if self.is_empty() {
|
||||||
return try { init };
|
return try { init };
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
/// An iterator able to yield elements from both ends.
|
/// An iterator able to yield elements from both ends.
|
||||||
///
|
///
|
||||||
@@ -218,7 +218,7 @@ pub trait DoubleEndedIterator: Iterator {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
let mut accum = init;
|
let mut accum = init;
|
||||||
while let Some(x) = self.next_back() {
|
while let Some(x) = self.next_back() {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// can't split that into multiple files.
|
// can't split that into multiple files.
|
||||||
|
|
||||||
use crate::cmp::{self, Ordering};
|
use crate::cmp::{self, Ordering};
|
||||||
use crate::ops::{ControlFlow, Try};
|
use crate::ops::{ControlFlow, TryWhereOutputEquals};
|
||||||
|
|
||||||
use super::super::TrustedRandomAccess;
|
use super::super::TrustedRandomAccess;
|
||||||
use super::super::{Chain, Cloned, Copied, Cycle, Enumerate, Filter, FilterMap, Fuse};
|
use super::super::{Chain, Cloned, Copied, Cycle, Enumerate, Filter, FilterMap, Fuse};
|
||||||
@@ -1999,7 +1999,7 @@ pub trait Iterator {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(B, Self::Item) -> R,
|
F: FnMut(B, Self::Item) -> R,
|
||||||
R: Try<Ok = B>,
|
R: TryWhereOutputEquals<B>,
|
||||||
{
|
{
|
||||||
let mut accum = init;
|
let mut accum = init;
|
||||||
while let Some(x) = self.next() {
|
while let Some(x) = self.next() {
|
||||||
@@ -2041,7 +2041,7 @@ pub trait Iterator {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(Self::Item) -> R,
|
F: FnMut(Self::Item) -> R,
|
||||||
R: Try<Ok = ()>,
|
R: TryWhereOutputEquals<()>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn call<T, R>(mut f: impl FnMut(T) -> R) -> impl FnMut((), T) -> R {
|
fn call<T, R>(mut f: impl FnMut(T) -> R) -> impl FnMut((), T) -> R {
|
||||||
@@ -2416,13 +2416,13 @@ pub trait Iterator {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: FnMut(&Self::Item) -> R,
|
F: FnMut(&Self::Item) -> R,
|
||||||
R: Try<Ok = bool>,
|
R: TryWhereOutputEquals<bool>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn check<F, T, R>(mut f: F) -> impl FnMut((), T) -> ControlFlow<Result<T, R::Error>>
|
fn check<F, T, R>(mut f: F) -> impl FnMut((), T) -> ControlFlow<Result<T, R::Error>>
|
||||||
where
|
where
|
||||||
F: FnMut(&T) -> R,
|
F: FnMut(&T) -> R,
|
||||||
R: Try<Ok = bool>,
|
R: TryWhereOutputEquals<bool>,
|
||||||
{
|
{
|
||||||
move |(), x| match f(&x).into_result() {
|
move |(), x| match f(&x).into_result() {
|
||||||
Ok(false) => ControlFlow::CONTINUE,
|
Ok(false) => ControlFlow::CONTINUE,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use crate::convert;
|
use crate::{convert, ops};
|
||||||
use crate::ops::{self, Try};
|
|
||||||
|
|
||||||
/// Used to tell an operation whether it should exit early or go on as usual.
|
/// Used to tell an operation whether it should exit early or go on as usual.
|
||||||
///
|
///
|
||||||
@@ -62,7 +61,7 @@ pub enum ControlFlow<B, C = ()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||||
impl<B, C> Try for ControlFlow<B, C> {
|
impl<B, C> ops::TryV1 for ControlFlow<B, C> {
|
||||||
type Ok = C;
|
type Ok = C;
|
||||||
type Error = B;
|
type Error = B;
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -182,14 +181,14 @@ impl<B, C> ControlFlow<B, C> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Try> ControlFlow<R, R::Ok> {
|
impl<R: ops::TryV1> ControlFlow<R, R::Ok> {
|
||||||
/// Create a `ControlFlow` from any type implementing `Try`.
|
/// Create a `ControlFlow` from any type implementing `Try`.
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_try(r: R) -> Self {
|
pub fn from_try(r: R) -> Self {
|
||||||
match Try::into_result(r) {
|
match R::into_result(r) {
|
||||||
Ok(v) => ControlFlow::Continue(v),
|
Ok(v) => ControlFlow::Continue(v),
|
||||||
Err(v) => ControlFlow::Break(Try::from_error(v)),
|
Err(v) => ControlFlow::Break(R::from_error(v)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +197,7 @@ impl<R: Try> ControlFlow<R, R::Ok> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_try(self) -> R {
|
pub fn into_try(self) -> R {
|
||||||
match self {
|
match self {
|
||||||
ControlFlow::Continue(v) => Try::from_ok(v),
|
ControlFlow::Continue(v) => R::from_ok(v),
|
||||||
ControlFlow::Break(v) => v,
|
ControlFlow::Break(v) => v,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,9 @@ pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
|
|||||||
#[unstable(feature = "try_trait", issue = "42327")]
|
#[unstable(feature = "try_trait", issue = "42327")]
|
||||||
pub use self::r#try::Try;
|
pub use self::r#try::Try;
|
||||||
|
|
||||||
|
#[unstable(feature = "try_trait_transition", reason = "for bootstrap", issue = "none")]
|
||||||
|
pub use self::r#try::Try as TryV1;
|
||||||
|
|
||||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||||
pub use self::try_trait::FromResidual;
|
pub use self::try_trait::FromResidual;
|
||||||
|
|
||||||
@@ -202,3 +205,19 @@ pub use self::unsize::DispatchFromDyn;
|
|||||||
|
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||||
pub use self::control_flow::ControlFlow;
|
pub use self::control_flow::ControlFlow;
|
||||||
|
|
||||||
|
/// [`TryV1`] and [`TryV2`] have different associated type names,
|
||||||
|
/// so rather than need `bootstrap` checks all over the library,
|
||||||
|
/// centralize the difference to this one trait alias.
|
||||||
|
///
|
||||||
|
/// As with all `try_trait_transition` stuff, this will be deleted
|
||||||
|
/// after the bootstrap compiler uses V2 for `?`.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(try_trait_transition)]
|
||||||
|
/// use std::ops::TryWhereOutputEquals;
|
||||||
|
/// fn foo<T, C>() where T: TryWhereOutputEquals<C> {}
|
||||||
|
/// foo::<Option<i32>, i32>();
|
||||||
|
/// ```
|
||||||
|
#[unstable(feature = "try_trait_transition", reason = "for bootstrap", issue = "none")]
|
||||||
|
pub trait TryWhereOutputEquals<T> = TryV1<Ok = T>;
|
||||||
|
|||||||
@@ -1644,7 +1644,7 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
|
|||||||
pub struct NoneError;
|
pub struct NoneError;
|
||||||
|
|
||||||
#[unstable(feature = "try_trait", issue = "42327")]
|
#[unstable(feature = "try_trait", issue = "42327")]
|
||||||
impl<T> ops::Try for Option<T> {
|
impl<T> ops::TryV1 for Option<T> {
|
||||||
type Ok = T;
|
type Ok = T;
|
||||||
type Error = NoneError;
|
type Error = NoneError;
|
||||||
|
|
||||||
|
|||||||
@@ -1627,7 +1627,7 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "try_trait", issue = "42327")]
|
#[unstable(feature = "try_trait", issue = "42327")]
|
||||||
impl<T, E> ops::Try for Result<T, E> {
|
impl<T, E> ops::TryV1 for Result<T, E> {
|
||||||
type Ok = T;
|
type Ok = T;
|
||||||
type Error = E;
|
type Error = E;
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ impl<'a> iter::Iterator for EscapeAscii<'a> {
|
|||||||
fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
|
fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
|
||||||
where
|
where
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: ops::Try<Ok = Acc>,
|
R: ops::TryWhereOutputEquals<Acc>,
|
||||||
{
|
{
|
||||||
self.inner.try_fold(init, fold)
|
self.inner.try_fold(init, fold)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::fmt::{self, Write};
|
|||||||
use crate::iter::TrustedRandomAccess;
|
use crate::iter::TrustedRandomAccess;
|
||||||
use crate::iter::{Chain, FlatMap, Flatten};
|
use crate::iter::{Chain, FlatMap, Flatten};
|
||||||
use crate::iter::{Copied, Filter, FusedIterator, Map, TrustedLen};
|
use crate::iter::{Copied, Filter, FusedIterator, Map, TrustedLen};
|
||||||
use crate::ops::Try;
|
use crate::ops::TryWhereOutputEquals;
|
||||||
use crate::option;
|
use crate::option;
|
||||||
use crate::slice::{self, Split as SliceSplit};
|
use crate::slice::{self, Split as SliceSplit};
|
||||||
|
|
||||||
@@ -1467,7 +1467,7 @@ macro_rules! escape_types_impls {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where
|
fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where
|
||||||
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
|
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: TryWhereOutputEquals<Acc>
|
||||||
{
|
{
|
||||||
self.inner.try_fold(init, fold)
|
self.inner.try_fold(init, fold)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#![stable(feature = "futures_api", since = "1.36.0")]
|
#![stable(feature = "futures_api", since = "1.36.0")]
|
||||||
|
|
||||||
use crate::convert;
|
use crate::convert;
|
||||||
use crate::ops::{self, ControlFlow, Try};
|
use crate::ops::{self, ControlFlow};
|
||||||
use crate::result::Result;
|
use crate::result::Result;
|
||||||
|
|
||||||
/// Indicates whether a value is available or if the current task has been
|
/// Indicates whether a value is available or if the current task has been
|
||||||
@@ -129,7 +129,7 @@ impl<T> From<T> for Poll<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<T, E> Try for Poll<Result<T, E>> {
|
impl<T, E> ops::TryV1 for Poll<Result<T, E>> {
|
||||||
type Ok = Poll<T>;
|
type Ok = Poll<T>;
|
||||||
type Error = E;
|
type Error = E;
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ impl<T, E, F: From<E>> ops::FromResidual<Result<convert::Infallible, E>> for Pol
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<T, E> Try for Poll<Option<Result<T, E>>> {
|
impl<T, E> ops::TryV1 for Poll<Option<Result<T, E>>> {
|
||||||
type Ok = Poll<Option<T>>;
|
type Ok = Poll<Option<T>>;
|
||||||
type Error = E;
|
type Error = E;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user