Skip to content

Commit 5c074b4

Browse files
committed
2024 edition
1 parent 0aa11a3 commit 5c074b4

File tree

3 files changed

+11
-32
lines changed

3 files changed

+11
-32
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
keywords = ["io", "async", "non-blocking"]
1111
categories = ["asynchronous"]
1212
exclude = [".gitignore"]
13-
edition = "2018"
13+
edition = "2024"
1414

1515
[dependencies]
1616
mio = "0.6.14"

src/channel.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use mio::{Evented, Poll, PollOpt, Ready, Registration, SetReadiness, Token};
44
use std::any::Any;
55
use std::error;
66
use std::sync::atomic::{AtomicUsize, Ordering};
7-
use std::sync::{mpsc, Arc};
7+
use std::sync::{Arc, mpsc};
88
use std::{fmt, io};
99

1010
/// Creates a new asynchronous channel, where the `Receiver` can be registered
@@ -274,10 +274,7 @@ impl Evented for ReceiverCtl {
274274
opts: PollOpt,
275275
) -> io::Result<()> {
276276
if self.registration.borrow().is_some() {
277-
return Err(io::Error::new(
278-
io::ErrorKind::Other,
279-
"receiver already registered",
280-
));
277+
return Err(io::Error::other("receiver already registered"));
281278
}
282279

283280
let (registration, set_readiness) = Registration::new2();
@@ -308,20 +305,14 @@ impl Evented for ReceiverCtl {
308305
) -> io::Result<()> {
309306
match self.registration.borrow() {
310307
Some(registration) => poll.reregister(registration, token, interest, opts),
311-
None => Err(io::Error::new(
312-
io::ErrorKind::Other,
313-
"receiver not registered",
314-
)),
308+
None => Err(io::Error::other("receiver not registered")),
315309
}
316310
}
317311

318312
fn deregister(&self, poll: &Poll) -> io::Result<()> {
319313
match self.registration.borrow() {
320314
Some(registration) => poll.deregister(registration),
321-
None => Err(io::Error::new(
322-
io::ErrorKind::Other,
323-
"receiver not registered",
324-
)),
315+
None => Err(io::Error::other("receiver not registered")),
325316
}
326317
}
327318
}

src/timer.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::convert;
33
use lazycell::LazyCell;
44
use mio::{Evented, Poll, PollOpt, Ready, Registration, SetReadiness, Token};
55
use slab::Slab;
6-
use std::sync::atomic::{AtomicUsize, Ordering};
76
use std::sync::Arc;
7+
use std::sync::atomic::{AtomicUsize, Ordering};
88
use std::time::{Duration, Instant};
99
use std::{cmp, fmt, io, iter, thread};
1010

@@ -185,9 +185,7 @@ impl<T> Timer<T> {
185185
let mut tick = duration_to_tick(delay_from_start, self.tick_ms);
186186
trace!(
187187
"setting timeout; delay={:?}; tick={:?}; current-tick={:?}",
188-
delay_from_start,
189-
tick,
190-
self.tick
188+
delay_from_start, tick, self.tick
191189
);
192190

193191
// Always target at least 1 tick in the future
@@ -258,8 +256,7 @@ impl<T> Timer<T> {
258256
fn poll_to(&mut self, mut target_tick: Tick) -> Option<T> {
259257
trace!(
260258
"tick_to; target_tick={}; current_tick={}",
261-
target_tick,
262-
self.tick
259+
target_tick, self.tick
263260
);
264261

265262
if target_tick < self.tick {
@@ -413,10 +410,7 @@ impl<T> Evented for Timer<T> {
413410
opts: PollOpt,
414411
) -> io::Result<()> {
415412
if self.inner.borrow().is_some() {
416-
return Err(io::Error::new(
417-
io::ErrorKind::Other,
418-
"timer already registered",
419-
));
413+
return Err(io::Error::other("timer already registered"));
420414
}
421415

422416
let (registration, set_readiness) = Registration::new2();
@@ -454,20 +448,14 @@ impl<T> Evented for Timer<T> {
454448
) -> io::Result<()> {
455449
match self.inner.borrow() {
456450
Some(inner) => poll.reregister(&inner.registration, token, interest, opts),
457-
None => Err(io::Error::new(
458-
io::ErrorKind::Other,
459-
"receiver not registered",
460-
)),
451+
None => Err(io::Error::other("receiver not registered")),
461452
}
462453
}
463454

464455
fn deregister(&self, poll: &Poll) -> io::Result<()> {
465456
match self.inner.borrow() {
466457
Some(inner) => poll.deregister(&inner.registration),
467-
None => Err(io::Error::new(
468-
io::ErrorKind::Other,
469-
"receiver not registered",
470-
)),
458+
None => Err(io::Error::other("receiver not registered")),
471459
}
472460
}
473461
}

0 commit comments

Comments
 (0)