1
1
cfg_unstable ! {
2
2
mod delay;
3
- mod select ;
4
- mod try_select ;
3
+ mod race ;
4
+ mod try_race ;
5
5
6
6
use std:: time:: Duration ;
7
7
8
8
use delay:: DelayFuture ;
9
- use select :: Select ;
10
- use try_select :: TrySelect ;
9
+ use race :: Race ;
10
+ use try_race :: TryRace ;
11
11
}
12
12
13
13
extension_trait ! {
@@ -160,30 +160,30 @@ extension_trait! {
160
160
let b = future::ready(1u8);
161
161
let c = future::ready(2u8);
162
162
163
- let f = a.select (b).select (c);
163
+ let f = a.race (b).race (c);
164
164
assert_eq!(f.await, 1u8);
165
165
# });
166
166
```
167
167
"# ]
168
168
#[ cfg( any( feature = "unstable" , feature = "docs" ) ) ]
169
169
#[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
170
- fn select <F >(
170
+ fn race <F >(
171
171
self ,
172
172
other: F
173
- ) -> impl Future <Output = <Self as std:: future:: Future >:: Output > [ Select <Self , F >]
173
+ ) -> impl Future <Output = <Self as std:: future:: Future >:: Output > [ Race <Self , F >]
174
174
where
175
175
Self : std:: future:: Future + Sized ,
176
176
F : std:: future:: Future <Output = <Self as std:: future:: Future >:: Output >,
177
177
{
178
- Select :: new( self , other)
178
+ Race :: new( self , other)
179
179
}
180
180
181
181
#[ doc = r#"
182
182
Waits for one of two similarly-typed fallible futures to complete.
183
183
184
184
Awaits multiple futures simultaneously, returning all results once complete.
185
185
186
- `try_select ` is similar to [`select `], but keeps going if a future
186
+ `try_race ` is similar to [`race `], but keeps going if a future
187
187
resolved to an error until all futures have been resolved. In which case
188
188
an error is returned.
189
189
@@ -203,23 +203,23 @@ extension_trait! {
203
203
let b = future::ready(Err(Error::from(ErrorKind::Other)));
204
204
let c = future::ready(Ok(1u8));
205
205
206
- let f = a.try_select (b).try_select (c);
206
+ let f = a.try_race (b).try_race (c);
207
207
assert_eq!(f.await?, 1u8);
208
208
#
209
209
# Ok(()) }) }
210
210
```
211
211
"# ]
212
212
#[ cfg( any( feature = "unstable" , feature = "docs" ) ) ]
213
213
#[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
214
- fn try_select <F : std:: future:: Future , T , E >(
214
+ fn try_race <F : std:: future:: Future , T , E >(
215
215
self ,
216
216
other: F
217
- ) -> impl Future <Output = <Self as std:: future:: Future >:: Output > [ TrySelect <Self , F >]
217
+ ) -> impl Future <Output = <Self as std:: future:: Future >:: Output > [ TryRace <Self , F >]
218
218
where
219
219
Self : std:: future:: Future <Output = Result <T , E >> + Sized ,
220
220
F : std:: future:: Future <Output = <Self as std:: future:: Future >:: Output >,
221
221
{
222
- TrySelect :: new( self , other)
222
+ TryRace :: new( self , other)
223
223
}
224
224
}
225
225
0 commit comments