@@ -242,17 +242,13 @@ impl<T: ?Sized> Spawn<T> {
242
242
/// Get a mutable reference to the object the Spawn is wrapping.
243
243
pub fn get_mut ( & mut self ) -> & mut T {
244
244
& mut self . obj
245
- }
246
- }
245
+ }
247
246
248
- impl < T > Spawn < T > {
249
247
/// Consume the Spawn, returning its inner object
250
- pub fn into_inner ( self ) -> T {
248
+ pub fn into_inner ( self ) -> T where T : Sized {
251
249
self . obj
252
250
}
253
- }
254
251
255
- impl < F : Future + ?Sized > Spawn < F > {
256
252
/// Polls the internal future, scheduling notifications to be sent to the
257
253
/// `notify` argument.
258
254
///
@@ -279,44 +275,43 @@ impl<F: Future + ?Sized> Spawn<F> {
279
275
/// the `id` specified very carefully, explicitly calling functions like the
280
276
/// `notify` argument's `clone_id` and `drop_id` functions. It should be
281
277
/// safe to encode a pointer itself into the `id` specified, such as an
282
- /// `Arc<T >` or a `Box<T >`. The `clone_id` and `drop_id` functions are then
278
+ /// `Arc<N >` or a `Box<N >`. The `clone_id` and `drop_id` functions are then
283
279
/// intended to be sufficient for the memory management related to that
284
280
/// pointer.
285
- pub fn poll_future_notify < T > ( & mut self ,
286
- notify : & T ,
287
- id : usize ) -> Poll < F :: Item , F :: Error >
288
- where T : Clone + Into < NotifyHandle > ,
281
+ pub fn poll_future_notify < N > ( & mut self ,
282
+ notify : & N ,
283
+ id : usize ) -> Poll < T :: Item , T :: Error >
284
+ where N : Clone + Into < NotifyHandle > ,
285
+ T : Future ,
289
286
{
290
287
let mk = || notify. clone ( ) . into ( ) ;
291
288
self . enter ( BorrowedUnpark :: new ( & mk, id) , |f| f. poll ( ) )
292
289
}
293
- }
294
290
295
- impl < S : Stream + ?Sized > Spawn < S > {
296
291
/// Like `poll_future_notify`, except polls the underlying stream.
297
- pub fn poll_stream_notify < T > ( & mut self ,
298
- notify : & T ,
292
+ pub fn poll_stream_notify < N > ( & mut self ,
293
+ notify : & N ,
299
294
id : usize )
300
- -> Poll < Option < S :: Item > , S :: Error >
301
- where T : Clone + Into < NotifyHandle > ,
295
+ -> Poll < Option < T :: Item > , T :: Error >
296
+ where N : Clone + Into < NotifyHandle > ,
297
+ T : Stream ,
302
298
{
303
299
let mk = || notify. clone ( ) . into ( ) ;
304
300
self . enter ( BorrowedUnpark :: new ( & mk, id) , |s| s. poll ( ) )
305
301
}
306
- }
307
302
308
- impl < S : Sink + ?Sized > Spawn < S > {
309
303
/// Invokes the underlying `start_send` method with this task in place.
310
304
///
311
305
/// If the underlying operation returns `NotReady` then the `notify` value
312
306
/// passed in will receive a notification when the operation is ready to be
313
307
/// attempted again.
314
- pub fn start_send_notify < T > ( & mut self ,
315
- value : S :: SinkItem ,
316
- notify : & T ,
308
+ pub fn start_send_notify < N > ( & mut self ,
309
+ value : T :: SinkItem ,
310
+ notify : & N ,
317
311
id : usize )
318
- -> StartSend < S :: SinkItem , S :: SinkError >
319
- where T : Clone + Into < NotifyHandle > ,
312
+ -> StartSend < T :: SinkItem , T :: SinkError >
313
+ where N : Clone + Into < NotifyHandle > ,
314
+ T : Sink ,
320
315
{
321
316
let mk = || notify. clone ( ) . into ( ) ;
322
317
self . enter ( BorrowedUnpark :: new ( & mk, id) , |s| s. start_send ( value) )
@@ -327,11 +322,12 @@ impl<S: Sink + ?Sized> Spawn<S> {
327
322
/// If the underlying operation returns `NotReady` then the `notify` value
328
323
/// passed in will receive a notification when the operation is ready to be
329
324
/// attempted again.
330
- pub fn poll_flush_notify < T > ( & mut self ,
331
- notify : & T ,
325
+ pub fn poll_flush_notify < N > ( & mut self ,
326
+ notify : & N ,
332
327
id : usize )
333
- -> Poll < ( ) , S :: SinkError >
334
- where T : Clone + Into < NotifyHandle > ,
328
+ -> Poll < ( ) , T :: SinkError >
329
+ where N : Clone + Into < NotifyHandle > ,
330
+ T : Sink ,
335
331
{
336
332
let mk = || notify. clone ( ) . into ( ) ;
337
333
self . enter ( BorrowedUnpark :: new ( & mk, id) , |s| s. poll_complete ( ) )
@@ -342,18 +338,17 @@ impl<S: Sink + ?Sized> Spawn<S> {
342
338
/// If the underlying operation returns `NotReady` then the `notify` value
343
339
/// passed in will receive a notification when the operation is ready to be
344
340
/// attempted again.
345
- pub fn close_notify < T > ( & mut self ,
346
- notify : & T ,
341
+ pub fn close_notify < N > ( & mut self ,
342
+ notify : & N ,
347
343
id : usize )
348
- -> Poll < ( ) , S :: SinkError >
349
- where T : Clone + Into < NotifyHandle > ,
344
+ -> Poll < ( ) , T :: SinkError >
345
+ where N : Clone + Into < NotifyHandle > ,
346
+ T : Sink ,
350
347
{
351
348
let mk = || notify. clone ( ) . into ( ) ;
352
349
self . enter ( BorrowedUnpark :: new ( & mk, id) , |s| s. close ( ) )
353
350
}
354
- }
355
351
356
- impl < T : ?Sized > Spawn < T > {
357
352
fn enter < F , R > ( & mut self , unpark : BorrowedUnpark , f : F ) -> R
358
353
where F : FnOnce ( & mut T ) -> R
359
354
{
0 commit comments