mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-21 00:00:10 +02:00
chore: formatting, docs and clippy (#2000)
This commit is contained in:
committed by
Carl Lerche
parent
248bf2144f
commit
3bff5a3ffe
@@ -1,4 +1,5 @@
|
||||
#![doc(html_root_url = "https://docs.rs/tokio-macros/0.2.1")]
|
||||
#![allow(clippy::needless_doctest_main)]
|
||||
#![warn(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#![doc(html_root_url = "https://docs.rs/tokio-util/0.2.0")]
|
||||
#![allow(clippy::needless_doctest_main)]
|
||||
#![warn(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#![doc(html_root_url = "https://docs.rs/tokio/0.2.6")]
|
||||
#![allow(clippy::cognitive_complexity)]
|
||||
#![allow(clippy::cognitive_complexity, clippy::needless_doctest_main)]
|
||||
#![warn(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
|
||||
@@ -30,7 +30,8 @@ impl<I> Unpin for Iter<I> {}
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn iter<I>(i: I) -> Iter<I::IntoIter>
|
||||
where I: IntoIterator,
|
||||
where
|
||||
I: IntoIterator,
|
||||
{
|
||||
Iter {
|
||||
iter: i.into_iter(),
|
||||
@@ -38,7 +39,8 @@ pub fn iter<I>(i: I) -> Iter<I::IntoIter>
|
||||
}
|
||||
|
||||
impl<I> Stream for Iter<I>
|
||||
where I: Iterator,
|
||||
where
|
||||
I: Iterator,
|
||||
{
|
||||
type Item = I::Item;
|
||||
|
||||
|
||||
+10
-12
@@ -20,15 +20,14 @@ where
|
||||
St: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Map")
|
||||
.field("stream", &self.stream)
|
||||
.finish()
|
||||
f.debug_struct("Map").field("stream", &self.stream).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, T, F> Map<St, F>
|
||||
where St: Stream,
|
||||
F: FnMut(St::Item) -> T,
|
||||
where
|
||||
St: Stream,
|
||||
F: FnMut(St::Item) -> T,
|
||||
{
|
||||
pub(super) fn new(stream: St, f: F) -> Map<St, F> {
|
||||
Map { stream, f }
|
||||
@@ -36,17 +35,16 @@ impl<St, T, F> Map<St, F>
|
||||
}
|
||||
|
||||
impl<St, F, T> Stream for Map<St, F>
|
||||
where St: Stream,
|
||||
F: FnMut(St::Item) -> T,
|
||||
where
|
||||
St: Stream,
|
||||
F: FnMut(St::Item) -> T,
|
||||
{
|
||||
type Item = T;
|
||||
|
||||
fn poll_next(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Option<T>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<T>> {
|
||||
self.as_mut()
|
||||
.project().stream
|
||||
.project()
|
||||
.stream
|
||||
.poll_next(cx)
|
||||
.map(|opt| opt.map(|x| (self.as_mut().project().f)(x)))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Stream utilities for Tokio.
|
||||
//!
|
||||
//! `Stream`s are an asynchoronous version of standard library's Iterator.
|
||||
//! A `Stream` is an asynchronous sequence of values. It can be thought of as an asynchronous version of the standard library's `Iterator` trait.
|
||||
//!
|
||||
//! This module provides helpers to work with them.
|
||||
|
||||
|
||||
@@ -22,10 +22,7 @@ impl<'a, St: ?Sized + Stream + Unpin> Next<'a, St> {
|
||||
impl<St: ?Sized + Stream + Unpin> Future for Next<'_, St> {
|
||||
type Output = Option<St::Item>;
|
||||
|
||||
fn poll(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
Pin::new(&mut self.stream).poll_next(cx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ fn acquire_mutex_in_drop() {
|
||||
|
||||
rt.spawn(async move {
|
||||
let _ = rx1.await;
|
||||
let _ = tx2.send(()).unwrap();
|
||||
tx2.send(()).unwrap();
|
||||
unreachable!();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::cognitive_complexity)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![cfg(feature = "sync")]
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ fn acquire_mutex_in_drop() {
|
||||
|
||||
local.spawn_local(async move {
|
||||
let _ = rx1.await;
|
||||
let _ = tx2.send(()).unwrap();
|
||||
tx2.send(()).unwrap();
|
||||
unreachable!();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user