Move docs of future and stream in Task
This commit is contained in:
parent
e86920be5b
commit
8efe161e3d
1 changed files with 18 additions and 18 deletions
|
|
@ -55,24 +55,6 @@ impl<T> Task<T> {
|
|||
Self::stream(stream.map(f))
|
||||
}
|
||||
|
||||
/// Creates a new [`Task`] that runs the given [`Future`] and produces
|
||||
/// its output.
|
||||
pub fn future(future: impl Future<Output = T> + MaybeSend + 'static) -> Self
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
Self::stream(stream::once(future))
|
||||
}
|
||||
|
||||
/// Creates a new [`Task`] that runs the given [`Stream`] and produces
|
||||
/// each of its items.
|
||||
pub fn stream(stream: impl Stream<Item = T> + MaybeSend + 'static) -> Self
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
Self(Some(boxed_stream(stream.map(Action::Output))))
|
||||
}
|
||||
|
||||
/// Combines the given tasks and produces a single [`Task`] that will run all of them
|
||||
/// in parallel.
|
||||
pub fn batch(tasks: impl IntoIterator<Item = Self>) -> Self
|
||||
|
|
@ -176,6 +158,24 @@ impl<T> Task<T> {
|
|||
))),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new [`Task`] that runs the given [`Future`] and produces
|
||||
/// its output.
|
||||
pub fn future(future: impl Future<Output = T> + MaybeSend + 'static) -> Self
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
Self::stream(stream::once(future))
|
||||
}
|
||||
|
||||
/// Creates a new [`Task`] that runs the given [`Stream`] and produces
|
||||
/// each of its items.
|
||||
pub fn stream(stream: impl Stream<Item = T> + MaybeSend + 'static) -> Self
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
Self(Some(boxed_stream(stream.map(Action::Output))))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Task<Option<T>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue