Skip to content

Commit 2321b84

Browse files
committed
Collapse Spawn impl blocks
1 parent 619634a commit 2321b84

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

src/task_impl/mod.rs

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,13 @@ impl<T: ?Sized> Spawn<T> {
242242
/// Get a mutable reference to the object the Spawn is wrapping.
243243
pub fn get_mut(&mut self) -> &mut T {
244244
&mut self.obj
245-
}
246-
}
245+
}
247246

248-
impl<T> Spawn<T> {
249247
/// Consume the Spawn, returning its inner object
250-
pub fn into_inner(self) -> T {
248+
pub fn into_inner(self) -> T where T: Sized {
251249
self.obj
252250
}
253-
}
254251

255-
impl<F: Future + ?Sized> Spawn<F> {
256252
/// Polls the internal future, scheduling notifications to be sent to the
257253
/// `notify` argument.
258254
///
@@ -279,44 +275,43 @@ impl<F: Future + ?Sized> Spawn<F> {
279275
/// the `id` specified very carefully, explicitly calling functions like the
280276
/// `notify` argument's `clone_id` and `drop_id` functions. It should be
281277
/// 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
283279
/// intended to be sufficient for the memory management related to that
284280
/// 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,
289286
{
290287
let mk = || notify.clone().into();
291288
self.enter(BorrowedUnpark::new(&mk, id), |f| f.poll())
292289
}
293-
}
294290

295-
impl<S: Stream + ?Sized> Spawn<S> {
296291
/// 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,
299294
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,
302298
{
303299
let mk = || notify.clone().into();
304300
self.enter(BorrowedUnpark::new(&mk, id), |s| s.poll())
305301
}
306-
}
307302

308-
impl<S: Sink + ?Sized> Spawn<S> {
309303
/// Invokes the underlying `start_send` method with this task in place.
310304
///
311305
/// If the underlying operation returns `NotReady` then the `notify` value
312306
/// passed in will receive a notification when the operation is ready to be
313307
/// 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,
317311
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,
320315
{
321316
let mk = || notify.clone().into();
322317
self.enter(BorrowedUnpark::new(&mk, id), |s| s.start_send(value))
@@ -327,11 +322,12 @@ impl<S: Sink + ?Sized> Spawn<S> {
327322
/// If the underlying operation returns `NotReady` then the `notify` value
328323
/// passed in will receive a notification when the operation is ready to be
329324
/// 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,
332327
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,
335331
{
336332
let mk = || notify.clone().into();
337333
self.enter(BorrowedUnpark::new(&mk, id), |s| s.poll_complete())
@@ -342,18 +338,17 @@ impl<S: Sink + ?Sized> Spawn<S> {
342338
/// If the underlying operation returns `NotReady` then the `notify` value
343339
/// passed in will receive a notification when the operation is ready to be
344340
/// attempted again.
345-
pub fn close_notify<T>(&mut self,
346-
notify: &T,
341+
pub fn close_notify<N>(&mut self,
342+
notify: &N,
347343
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,
350347
{
351348
let mk = || notify.clone().into();
352349
self.enter(BorrowedUnpark::new(&mk, id), |s| s.close())
353350
}
354-
}
355351

356-
impl<T: ?Sized> Spawn<T> {
357352
fn enter<F, R>(&mut self, unpark: BorrowedUnpark, f: F) -> R
358353
where F: FnOnce(&mut T) -> R
359354
{

0 commit comments

Comments
 (0)