From f6a729925ddeb6063fa8c4b03d6621c1c35f0cc8 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Wed, 11 Oct 2023 00:33:49 -0700 Subject: [PATCH] chore(hydroflow): fix `clippy::items_after_test_module`, simplify rustdoc links (#942) --- hydroflow/src/scheduled/graph_ext.rs | 2 +- hydroflow/src/util/mod.rs | 59 ++++++++++++++-------------- lattices/src/collections.rs | 2 +- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/hydroflow/src/scheduled/graph_ext.rs b/hydroflow/src/scheduled/graph_ext.rs index db8b48726e0e..252c4269a4d3 100644 --- a/hydroflow/src/scheduled/graph_ext.rs +++ b/hydroflow/src/scheduled/graph_ext.rs @@ -1,4 +1,4 @@ -//! Helper extensions for [`Hydroflow`](super::graph::Hydroflow). +//! Helper extensions for [`Hydroflow`]. #![allow(missing_docs)] use core::task; diff --git a/hydroflow/src/util/mod.rs b/hydroflow/src/util/mod.rs index f3080c90cde3..fdc52039ba5b 100644 --- a/hydroflow/src/util/mod.rs +++ b/hydroflow/src/util/mod.rs @@ -27,8 +27,10 @@ pub use socket::*; #[cfg(feature = "cli_integration")] pub mod cli; +use std::io::Read; use std::net::SocketAddr; use std::num::NonZeroUsize; +use std::process::{Child, ChildStdin, ChildStdout, Stdio}; use std::task::{Context, Poll}; use bincode; @@ -229,36 +231,6 @@ where slice.sort_unstable_by(|a, b| f(a).cmp(f(b))) } -#[cfg(test)] -mod test { - use super::*; - - #[test] - pub fn test_collect_ready() { - let (send, mut recv) = unbounded_channel::(); - for x in 0..1000 { - send.send(x).unwrap(); - } - assert_eq!(1000, collect_ready::, _>(&mut recv).len()); - } - - #[crate::test] - pub async fn test_collect_ready_async() { - // Tokio unbounded channel returns items in 128 item long chunks, so we have to be careful that everything gets returned. - let (send, mut recv) = unbounded_channel::(); - for x in 0..1000 { - send.send(x).unwrap(); - } - assert_eq!( - 1000, - collect_ready_async::, _>(&mut recv).await.len() - ); - } -} - -use std::io::Read; -use std::process::{Child, ChildStdin, ChildStdout, Stdio}; - /// When a child process is spawned often you want to wait until the child process is ready before moving on. /// One way to do that synchronization is by waiting for the child process to output something and match regex against that output. /// For example, you could wait until the child process outputs "Client live!" which would indicate that it is ready to receive input now on stdin. @@ -351,3 +323,30 @@ where } }) } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + pub fn test_collect_ready() { + let (send, mut recv) = unbounded_channel::(); + for x in 0..1000 { + send.send(x).unwrap(); + } + assert_eq!(1000, collect_ready::, _>(&mut recv).len()); + } + + #[crate::test] + pub async fn test_collect_ready_async() { + // Tokio unbounded channel returns items in 128 item long chunks, so we have to be careful that everything gets returned. + let (send, mut recv) = unbounded_channel::(); + for x in 0..1000 { + send.send(x).unwrap(); + } + assert_eq!( + 1000, + collect_ready_async::, _>(&mut recv).await.len() + ); + } +} diff --git a/lattices/src/collections.rs b/lattices/src/collections.rs index 2cc81e5d4677..6c6cd18f7811 100644 --- a/lattices/src/collections.rs +++ b/lattices/src/collections.rs @@ -1,4 +1,4 @@ -//! Simple singleton or array collection with [`cc_traits`](crate::cc_traits) implementations. +//! Simple singleton or array collection with [`cc_traits`] implementations. use std::borrow::Borrow; use std::hash::Hash;