We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ae41d45 + fe49f26 commit c2a084eCopy full SHA for c2a084e
examples/a-chat/main.rs
@@ -8,6 +8,6 @@ fn main() -> Result<()> {
8
match (args.nth(1).as_ref().map(String::as_str), args.next()) {
9
(Some("client"), None) => client::main(),
10
(Some("server"), None) => server::main(),
11
- _ => Err("Usage: a-chat [client|server]")?,
+ _ => Err("Usage: a-chat [client|server]".into()),
12
}
13
examples/a-chat/server.rs
@@ -45,7 +45,7 @@ async fn connection_loop(mut broker: Sender<Event>, stream: TcpStream) -> Result
45
let mut lines = reader.lines();
46
47
let name = match lines.next().await {
48
- None => Err("peer disconnected immediately")?,
+ None => returnErr("peer disconnected immediately".into()),
49
Some(line) => line?,
50
};
51
let (_shutdown_sender, shutdown_receiver) = mpsc::unbounded::<Void>();
src/stream/interval.rs
@@ -115,6 +115,7 @@ fn next_interval(prev: Instant, now: Instant, interval: Duration) -> Instant {
115
#[cfg(test)]
116
mod test {
117
use super::next_interval;
118
+ use std::cmp::Ordering;
119
use std::time::{Duration, Instant};
120
121
struct Timeline(Instant);
@@ -138,12 +139,10 @@ mod test {
138
139
// The math around Instant/Duration isn't 100% precise due to rounding
140
// errors, see #249 for more info
141
fn almost_eq(a: Instant, b: Instant) -> bool {
- 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)
+ match a.cmp(&b) {
+ Ordering::Equal => true,
+ Ordering::Greater => a - b < Duration::from_millis(1),
+ Ordering::Less => b - a < Duration::from_millis(1),
147
148
149
src/task/block_on.rs
@@ -154,6 +154,7 @@ where
154
155
fn vtable() -> &'static RawWakerVTable {
156
unsafe fn clone_raw(ptr: *const ()) -> RawWaker {
157
+ #![allow(clippy::redundant_clone)]
158
let arc = ManuallyDrop::new(Arc::from_raw(ptr as *const Parker));
159
mem::forget(arc.clone());
160
RawWaker::new(ptr, vtable())
tests/buf_writer.rs
@@ -4,6 +4,7 @@ use async_std::task;
4
5
#[test]
6
fn test_buffered_writer() {
7
+ #![allow(clippy::cognitive_complexity)]
task::block_on(async {
let inner = Vec::new();
let mut writer = BufWriter::with_capacity(2, inner);
tests/channel.rs
@@ -37,6 +37,7 @@ fn capacity() {
37
38
39
fn len_empty_full() {
40
41
42
let (s, r) = channel(2);
43
tests/rwlock.rs
@@ -13,7 +13,7 @@ use futures::channel::mpsc;
/// Generates a random number in `0..n`.
14
pub fn random(n: u32) -> u32 {
15
thread_local! {
16
- static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1406868647));
+ static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1_406_868_647));
17
18
19
RNG.with(|rng| {
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments