Skip to content

Commit c10eec3

Browse files
committed
Bootstrapping preparation for the library
Since just `ops::Try` will need to change meaning.
1 parent d44f647 commit c10eec3

33 files changed

+123
-104
lines changed

library/alloc/src/collections/vec_deque/iter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::fmt;
22
use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess};
3-
use core::ops::Try;
3+
use core::ops::TryWhereOutputEquals;
44

55
use super::{count, wrap_index, RingSlices};
66

@@ -66,7 +66,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
6666
where
6767
Self: Sized,
6868
F: FnMut(B, Self::Item) -> R,
69-
R: Try<Ok = B>,
69+
R: TryWhereOutputEquals<B>,
7070
{
7171
let (mut iter, final_res);
7272
if self.tail <= self.head {
@@ -140,7 +140,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
140140
where
141141
Self: Sized,
142142
F: FnMut(B, Self::Item) -> R,
143-
R: Try<Ok = B>,
143+
R: TryWhereOutputEquals<B>,
144144
{
145145
let (mut iter, final_res);
146146
if self.tail <= self.head {

library/alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
#![feature(alloc_layout_extra)]
142142
#![feature(trusted_random_access)]
143143
#![feature(try_trait)]
144+
#![feature(try_trait_transition)]
144145
#![feature(min_type_alias_impl_trait)]
145146
#![feature(associated_type_bounds)]
146147
#![feature(slice_group_by)]

library/core/src/iter/adapters/chain.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::iter::{DoubleEndedIterator, FusedIterator, Iterator, TrustedLen};
2-
use crate::ops::Try;
2+
use crate::ops::TryWhereOutputEquals;
33

44
/// An iterator that links two iterators together, in a chain.
55
///
@@ -98,7 +98,7 @@ where
9898
where
9999
Self: Sized,
100100
F: FnMut(Acc, Self::Item) -> R,
101-
R: Try<Ok = Acc>,
101+
R: TryWhereOutputEquals<Acc>,
102102
{
103103
if let Some(ref mut a) = self.a {
104104
acc = a.try_fold(acc, &mut f)?;
@@ -281,7 +281,7 @@ where
281281
where
282282
Self: Sized,
283283
F: FnMut(Acc, Self::Item) -> R,
284-
R: Try<Ok = Acc>,
284+
R: TryWhereOutputEquals<Acc>,
285285
{
286286
if let Some(ref mut b) = self.b {
287287
acc = b.try_rfold(acc, &mut f)?;

library/core/src/iter/adapters/cloned.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess};
22
use crate::iter::{FusedIterator, TrustedLen};
3-
use crate::ops::Try;
3+
use crate::ops::TryWhereOutputEquals;
44

55
/// An iterator that clones the elements of an underlying iterator.
66
///
@@ -46,7 +46,7 @@ where
4646
where
4747
Self: Sized,
4848
F: FnMut(B, Self::Item) -> R,
49-
R: Try<Ok = B>,
49+
R: TryWhereOutputEquals<B>,
5050
{
5151
self.it.try_fold(init, clone_try_fold(f))
5252
}
@@ -82,7 +82,7 @@ where
8282
where
8383
Self: Sized,
8484
F: FnMut(B, Self::Item) -> R,
85-
R: Try<Ok = B>,
85+
R: TryWhereOutputEquals<B>,
8686
{
8787
self.it.try_rfold(init, clone_try_fold(f))
8888
}

library/core/src/iter/adapters/copied.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess};
22
use crate::iter::{FusedIterator, TrustedLen};
3-
use crate::ops::Try;
3+
use crate::ops::TryWhereOutputEquals;
44

55
/// An iterator that copies the elements of an underlying iterator.
66
///
@@ -50,7 +50,7 @@ where
5050
where
5151
Self: Sized,
5252
F: FnMut(B, Self::Item) -> R,
53-
R: Try<Ok = B>,
53+
R: TryWhereOutputEquals<B>,
5454
{
5555
self.it.try_fold(init, copy_try_fold(f))
5656
}
@@ -98,7 +98,7 @@ where
9898
where
9999
Self: Sized,
100100
F: FnMut(B, Self::Item) -> R,
101-
R: Try<Ok = B>,
101+
R: TryWhereOutputEquals<B>,
102102
{
103103
self.it.try_rfold(init, copy_try_fold(f))
104104
}

library/core/src/iter/adapters/cycle.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{iter::FusedIterator, ops::Try};
1+
use crate::{iter::FusedIterator, ops::TryWhereOutputEquals};
22

33
/// An iterator that repeats endlessly.
44
///
@@ -53,7 +53,7 @@ where
5353
fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
5454
where
5555
F: FnMut(Acc, Self::Item) -> R,
56-
R: Try<Ok = Acc>,
56+
R: TryWhereOutputEquals<Acc>,
5757
{
5858
// fully iterate the current iterator. this is necessary because
5959
// `self.iter` may be empty even when `self.orig` isn't

library/core/src/iter/adapters/enumerate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::iter::adapters::{zip::try_get_unchecked, SourceIter, TrustedRandomAccess};
22
use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen};
3-
use crate::ops::Try;
3+
use crate::ops::TryWhereOutputEquals;
44

55
/// An iterator that yields the current count and the element during iteration.
66
///
@@ -71,7 +71,7 @@ where
7171
where
7272
Self: Sized,
7373
Fold: FnMut(Acc, Self::Item) -> R,
74-
R: Try<Ok = Acc>,
74+
R: TryWhereOutputEquals<Acc>,
7575
{
7676
#[inline]
7777
fn enumerate<'a, T, Acc, R>(
@@ -150,7 +150,7 @@ where
150150
where
151151
Self: Sized,
152152
Fold: FnMut(Acc, Self::Item) -> R,
153-
R: Try<Ok = Acc>,
153+
R: TryWhereOutputEquals<Acc>,
154154
{
155155
// Can safely add and subtract the count, as `ExactSizeIterator` promises
156156
// that the number of elements fits into a `usize`.

library/core/src/iter/adapters/filter.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fmt;
22
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
3-
use crate::ops::Try;
3+
use crate::ops::TryWhereOutputEquals;
44

55
/// An iterator that filters the elements of `iter` with `predicate`.
66
///
@@ -37,7 +37,7 @@ fn filter_fold<T, Acc>(
3737
move |acc, item| if predicate(&item) { fold(acc, item) } else { acc }
3838
}
3939

40-
fn filter_try_fold<'a, T, Acc, R: Try<Ok = Acc>>(
40+
fn filter_try_fold<'a, T, Acc, R: TryWhereOutputEquals<Acc>>(
4141
predicate: &'a mut impl FnMut(&T) -> bool,
4242
mut fold: impl FnMut(Acc, T) -> R + 'a,
4343
) -> impl FnMut(Acc, T) -> R + 'a {
@@ -88,7 +88,7 @@ where
8888
where
8989
Self: Sized,
9090
Fold: FnMut(Acc, Self::Item) -> R,
91-
R: Try<Ok = Acc>,
91+
R: TryWhereOutputEquals<Acc>,
9292
{
9393
self.iter.try_fold(init, filter_try_fold(&mut self.predicate, fold))
9494
}
@@ -117,7 +117,7 @@ where
117117
where
118118
Self: Sized,
119119
Fold: FnMut(Acc, Self::Item) -> R,
120-
R: Try<Ok = Acc>,
120+
R: TryWhereOutputEquals<Acc>,
121121
{
122122
self.iter.try_rfold(init, filter_try_fold(&mut self.predicate, fold))
123123
}

library/core/src/iter/adapters/filter_map.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fmt;
22
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
3-
use crate::ops::{ControlFlow, Try};
3+
use crate::ops::{ControlFlow, TryWhereOutputEquals};
44

55
/// An iterator that uses `f` to both filter and map elements from `iter`.
66
///
@@ -39,7 +39,7 @@ fn filter_map_fold<T, B, Acc>(
3939
}
4040
}
4141

42-
fn filter_map_try_fold<'a, T, B, Acc, R: Try<Ok = Acc>>(
42+
fn filter_map_try_fold<'a, T, B, Acc, R: TryWhereOutputEquals<Acc>>(
4343
f: &'a mut impl FnMut(T) -> Option<B>,
4444
mut fold: impl FnMut(Acc, B) -> R + 'a,
4545
) -> impl FnMut(Acc, T) -> R + 'a {
@@ -72,7 +72,7 @@ where
7272
where
7373
Self: Sized,
7474
Fold: FnMut(Acc, Self::Item) -> R,
75-
R: Try<Ok = Acc>,
75+
R: TryWhereOutputEquals<Acc>,
7676
{
7777
self.iter.try_fold(init, filter_map_try_fold(&mut self.f, fold))
7878
}
@@ -111,7 +111,7 @@ where
111111
where
112112
Self: Sized,
113113
Fold: FnMut(Acc, Self::Item) -> R,
114-
R: Try<Ok = Acc>,
114+
R: TryWhereOutputEquals<Acc>,
115115
{
116116
self.iter.try_rfold(init, filter_map_try_fold(&mut self.f, fold))
117117
}

library/core/src/iter/adapters/flatten.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fmt;
22
use crate::iter::{DoubleEndedIterator, Fuse, FusedIterator, Iterator, Map};
3-
use crate::ops::Try;
3+
use crate::ops::TryWhereOutputEquals;
44

55
/// An iterator that maps each element to an iterator, and yields the elements
66
/// of the produced iterators.
@@ -61,7 +61,7 @@ where
6161
where
6262
Self: Sized,
6363
Fold: FnMut(Acc, Self::Item) -> R,
64-
R: Try<Ok = Acc>,
64+
R: TryWhereOutputEquals<Acc>,
6565
{
6666
self.inner.try_fold(init, fold)
6767
}
@@ -91,7 +91,7 @@ where
9191
where
9292
Self: Sized,
9393
Fold: FnMut(Acc, Self::Item) -> R,
94-
R: Try<Ok = Acc>,
94+
R: TryWhereOutputEquals<Acc>,
9595
{
9696
self.inner.try_rfold(init, fold)
9797
}
@@ -178,7 +178,7 @@ where
178178
where
179179
Self: Sized,
180180
Fold: FnMut(Acc, Self::Item) -> R,
181-
R: Try<Ok = Acc>,
181+
R: TryWhereOutputEquals<Acc>,
182182
{
183183
self.inner.try_fold(init, fold)
184184
}
@@ -208,7 +208,7 @@ where
208208
where
209209
Self: Sized,
210210
Fold: FnMut(Acc, Self::Item) -> R,
211-
R: Try<Ok = Acc>,
211+
R: TryWhereOutputEquals<Acc>,
212212
{
213213
self.inner.try_rfold(init, fold)
214214
}
@@ -293,10 +293,10 @@ where
293293
where
294294
Self: Sized,
295295
Fold: FnMut(Acc, Self::Item) -> R,
296-
R: Try<Ok = Acc>,
296+
R: TryWhereOutputEquals<Acc>,
297297
{
298298
#[inline]
299-
fn flatten<'a, T: IntoIterator, Acc, R: Try<Ok = Acc>>(
299+
fn flatten<'a, T: IntoIterator, Acc, R: TryWhereOutputEquals<Acc>>(
300300
frontiter: &'a mut Option<T::IntoIter>,
301301
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
302302
) -> impl FnMut(Acc, T) -> R + 'a {
@@ -382,10 +382,10 @@ where
382382
where
383383
Self: Sized,
384384
Fold: FnMut(Acc, Self::Item) -> R,
385-
R: Try<Ok = Acc>,
385+
R: TryWhereOutputEquals<Acc>,
386386
{
387387
#[inline]
388-
fn flatten<'a, T: IntoIterator, Acc, R: Try<Ok = Acc>>(
388+
fn flatten<'a, T: IntoIterator, Acc, R: TryWhereOutputEquals<Acc>>(
389389
backiter: &'a mut Option<T::IntoIter>,
390390
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
391391
) -> impl FnMut(Acc, T) -> R + 'a

library/core/src/iter/adapters/fuse.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::iter::adapters::{zip::try_get_unchecked, InPlaceIterable, SourceIter}
33
use crate::iter::{
44
DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess,
55
};
6-
use crate::ops::Try;
6+
use crate::ops::TryWhereOutputEquals;
77

88
/// An iterator that yields `None` forever after the underlying iterator
99
/// yields `None` once.
@@ -92,7 +92,7 @@ where
9292
where
9393
Self: Sized,
9494
Fold: FnMut(Acc, Self::Item) -> R,
95-
R: Try<Ok = Acc>,
95+
R: TryWhereOutputEquals<Acc>,
9696
{
9797
FuseImpl::try_fold(self, acc, fold)
9898
}
@@ -148,7 +148,7 @@ where
148148
where
149149
Self: Sized,
150150
Fold: FnMut(Acc, Self::Item) -> R,
151-
R: Try<Ok = Acc>,
151+
R: TryWhereOutputEquals<Acc>,
152152
{
153153
FuseImpl::try_rfold(self, acc, fold)
154154
}
@@ -219,7 +219,7 @@ trait FuseImpl<I> {
219219
where
220220
Self: Sized,
221221
Fold: FnMut(Acc, Self::Item) -> R,
222-
R: Try<Ok = Acc>;
222+
R: TryWhereOutputEquals<Acc>;
223223
fn fold<Acc, Fold>(self, acc: Acc, fold: Fold) -> Acc
224224
where
225225
Fold: FnMut(Acc, Self::Item) -> Acc;
@@ -238,7 +238,7 @@ trait FuseImpl<I> {
238238
where
239239
Self: Sized,
240240
Fold: FnMut(Acc, Self::Item) -> R,
241-
R: Try<Ok = Acc>,
241+
R: TryWhereOutputEquals<Acc>,
242242
I: DoubleEndedIterator;
243243
fn rfold<Acc, Fold>(self, acc: Acc, fold: Fold) -> Acc
244244
where
@@ -305,7 +305,7 @@ where
305305
where
306306
Self: Sized,
307307
Fold: FnMut(Acc, Self::Item) -> R,
308-
R: Try<Ok = Acc>,
308+
R: TryWhereOutputEquals<Acc>,
309309
{
310310
if let Some(ref mut iter) = self.iter {
311311
acc = iter.try_fold(acc, fold)?;
@@ -354,7 +354,7 @@ where
354354
where
355355
Self: Sized,
356356
Fold: FnMut(Acc, Self::Item) -> R,
357-
R: Try<Ok = Acc>,
357+
R: TryWhereOutputEquals<Acc>,
358358
I: DoubleEndedIterator,
359359
{
360360
if let Some(ref mut iter) = self.iter {
@@ -443,7 +443,7 @@ where
443443
where
444444
Self: Sized,
445445
Fold: FnMut(Acc, Self::Item) -> R,
446-
R: Try<Ok = Acc>,
446+
R: TryWhereOutputEquals<Acc>,
447447
{
448448
unchecked!(self).try_fold(init, fold)
449449
}
@@ -485,7 +485,7 @@ where
485485
where
486486
Self: Sized,
487487
Fold: FnMut(Acc, Self::Item) -> R,
488-
R: Try<Ok = Acc>,
488+
R: TryWhereOutputEquals<Acc>,
489489
I: DoubleEndedIterator,
490490
{
491491
unchecked!(self).try_rfold(init, fold)

library/core/src/iter/adapters/inspect.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fmt;
22
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
3-
use crate::ops::Try;
3+
use crate::ops::TryWhereOutputEquals;
44

55
/// An iterator that calls a function with a reference to each element before
66
/// yielding it.
@@ -87,7 +87,7 @@ where
8787
where
8888
Self: Sized,
8989
Fold: FnMut(Acc, Self::Item) -> R,
90-
R: Try<Ok = Acc>,
90+
R: TryWhereOutputEquals<Acc>,
9191
{
9292
self.iter.try_fold(init, inspect_try_fold(&mut self.f, fold))
9393
}
@@ -117,7 +117,7 @@ where
117117
where
118118
Self: Sized,
119119
Fold: FnMut(Acc, Self::Item) -> R,
120-
R: Try<Ok = Acc>,
120+
R: TryWhereOutputEquals<Acc>,
121121
{
122122
self.iter.try_rfold(init, inspect_try_fold(&mut self.f, fold))
123123
}

0 commit comments

Comments
 (0)