Skip to content

Commit c2a084e

Browse files
authored
Merge pull request #393 from k-nasa/fix_clippy
Fix clippy warnings
2 parents ae41d45 + fe49f26 commit c2a084e

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

examples/a-chat/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ fn main() -> Result<()> {
88
match (args.nth(1).as_ref().map(String::as_str), args.next()) {
99
(Some("client"), None) => client::main(),
1010
(Some("server"), None) => server::main(),
11-
_ => Err("Usage: a-chat [client|server]")?,
11+
_ => Err("Usage: a-chat [client|server]".into()),
1212
}
1313
}

examples/a-chat/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async fn connection_loop(mut broker: Sender<Event>, stream: TcpStream) -> Result
4545
let mut lines = reader.lines();
4646

4747
let name = match lines.next().await {
48-
None => Err("peer disconnected immediately")?,
48+
None => return Err("peer disconnected immediately".into()),
4949
Some(line) => line?,
5050
};
5151
let (_shutdown_sender, shutdown_receiver) = mpsc::unbounded::<Void>();

src/stream/interval.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ fn next_interval(prev: Instant, now: Instant, interval: Duration) -> Instant {
115115
#[cfg(test)]
116116
mod test {
117117
use super::next_interval;
118+
use std::cmp::Ordering;
118119
use std::time::{Duration, Instant};
119120

120121
struct Timeline(Instant);
@@ -138,12 +139,10 @@ mod test {
138139
// The math around Instant/Duration isn't 100% precise due to rounding
139140
// errors, see #249 for more info
140141
fn almost_eq(a: Instant, b: Instant) -> bool {
141-
if a == b {
142-
true
143-
} else if a > b {
144-
a - b < Duration::from_millis(1)
145-
} else {
146-
b - a < Duration::from_millis(1)
142+
match a.cmp(&b) {
143+
Ordering::Equal => true,
144+
Ordering::Greater => a - b < Duration::from_millis(1),
145+
Ordering::Less => b - a < Duration::from_millis(1),
147146
}
148147
}
149148

src/task/block_on.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ where
154154

155155
fn vtable() -> &'static RawWakerVTable {
156156
unsafe fn clone_raw(ptr: *const ()) -> RawWaker {
157+
#![allow(clippy::redundant_clone)]
157158
let arc = ManuallyDrop::new(Arc::from_raw(ptr as *const Parker));
158159
mem::forget(arc.clone());
159160
RawWaker::new(ptr, vtable())

tests/buf_writer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use async_std::task;
44

55
#[test]
66
fn test_buffered_writer() {
7+
#![allow(clippy::cognitive_complexity)]
78
task::block_on(async {
89
let inner = Vec::new();
910
let mut writer = BufWriter::with_capacity(2, inner);

tests/channel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ fn capacity() {
3737

3838
#[test]
3939
fn len_empty_full() {
40+
#![allow(clippy::cognitive_complexity)]
4041
task::block_on(async {
4142
let (s, r) = channel(2);
4243

tests/rwlock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use futures::channel::mpsc;
1313
/// Generates a random number in `0..n`.
1414
pub fn random(n: u32) -> u32 {
1515
thread_local! {
16-
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1406868647));
16+
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1_406_868_647));
1717
}
1818

1919
RNG.with(|rng| {

0 commit comments

Comments
 (0)