Skip to content

Commit d0e257f

Browse files
Refactor: fix Clippy lints and format code
1 parent 2fd9743 commit d0e257f

File tree

10 files changed

+10
-46
lines changed

10 files changed

+10
-46
lines changed

example/Cargo.toml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ path = "basic.rs"
4343
name = "chat"
4444
path = "chat.rs"
4545

46-
[[example]]
47-
name = "connect"
48-
path = "connect.rs"
49-
5046
[[example]]
5147
name = "echo-udp"
5248
path = "echo-udp.rs"
@@ -75,34 +71,10 @@ path = "tinydb.rs"
7571
name = "udp-client"
7672
path = "udp-client.rs"
7773

78-
[[example]]
79-
name = "udp-codec"
80-
path = "udp-codec.rs"
81-
8274
[[example]]
8375
name = "tinyhttp"
8476
path = "tinyhttp.rs"
8577

86-
[[example]]
87-
name = "custom-executor"
88-
path = "custom-executor.rs"
89-
90-
[[example]]
91-
name = "custom-executor-tokio-context"
92-
path = "custom-executor-tokio-context.rs"
93-
94-
[[example]]
95-
name = "named-pipe"
96-
path = "named-pipe.rs"
97-
98-
[[example]]
99-
name = "named-pipe-ready"
100-
path = "named-pipe-ready.rs"
101-
102-
[[example]]
103-
name = "named-pipe-multi-client"
104-
path = "named-pipe-multi-client.rs"
105-
10678
[[example]]
10779
name = "hyper-server"
10880
path = "hyper-server/main.rs"

example/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
66
async fn main() -> io::Result<()> {
77
let listener = TcpListener::bind("127.0.0.1:8080").await?;
88
println!("{listener:#?}");
9-
9+
1010
loop {
1111
let (mut stream, addr) = listener.accept().await?;
1212
println!("[INCOMING] {addr:?}");

example/proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
2323
#![warn(rust_2018_idioms)]
2424

25-
use tokio::io::copy_bidirectional;
2625
use nio::net::{TcpListener, TcpStream};
26+
use tokio::io::copy_bidirectional;
2727

2828
use futures::FutureExt;
2929
use std::env;

src/fs/copy.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::path::Path;
1717
/// # Ok(())
1818
/// # }
1919
/// ```
20-
2120
pub async fn copy(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<u64, std::io::Error> {
2221
let from = from.as_ref().to_owned();
2322
let to = to.as_ref().to_owned();

src/fs/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ where
240240
{
241241
match crate::task::spawn_blocking(f).await {
242242
Ok(res) => res,
243-
Err(_) => Err(io::Error::new(
244-
io::ErrorKind::Other,
245-
"background task failed",
246-
)),
243+
Err(_) => Err(io::Error::other("background task failed")),
247244
}
248245
}

src/io/scheduled_io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Event {
6565
let _ = self.readiness.fetch_update(AcqRel, Acquire, |state| {
6666
let mut state = ReadinessVersion::from_usize(state);
6767
state.version = state.version.wrapping_add(1);
68-
state.readiness = state.readiness | readiness;
68+
state.readiness |= readiness;
6969
Some(state.into_usize())
7070
});
7171
self.waker.wake();

src/macros/cfg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ macro_rules! cfg_unix {
3737
}
3838
}
3939

40-
4140
macro_rules! cfg_aio {
4241
($($item:item)*) => {
4342
$(

src/runtime/task/error.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,10 @@ impl fmt::Debug for JoinError {
157157

158158
impl From<JoinError> for io::Error {
159159
fn from(src: JoinError) -> io::Error {
160-
io::Error::new(
161-
io::ErrorKind::Other,
162-
match src.repr {
163-
Repr::Cancelled => "task was cancelled",
164-
Repr::Panic(_) => "task panicked",
165-
},
166-
)
160+
io::Error::other(match src.repr {
161+
Repr::Cancelled => "task was cancelled",
162+
Repr::Panic(_) => "task panicked",
163+
})
167164
}
168165
}
169166

src/time/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ mod timeout;
44
pub(crate) mod timer;
55

66
pub use error::TimeoutError;
7+
pub use std::time::Duration;
78
pub use timeout::{timeout, Timeout};
89
pub use timer::{sleep, Sleep};
9-
pub use std::time::Duration;

src/time/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl PartialEq for Timer {
3636
}
3737
impl PartialOrd for Timer {
3838
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
39-
Some(other.deadline.cmp(&self.deadline))
39+
Some(self.cmp(other))
4040
}
4141
}
4242
impl Ord for Timer {

0 commit comments

Comments
 (0)