mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
io: bring back split utility (#1521)
Bring back `split` utility as a free fn instead of a method on `AsyncRead`. This utility wraps the `stream` in an `Arc` and uses mutual exclusion to ensure correct access. Additionally, the specialized `split_mut` fn on TcpStream and UdsStream is promoted to `split`.
This commit is contained in:
@@ -11,10 +11,10 @@ use tokio::prelude::*;
|
||||
/// writing by reading to the end of stream on the other side of the connection.
|
||||
#[tokio::test]
|
||||
async fn split() -> std::io::Result<()> {
|
||||
let (a, mut b) = UnixStream::pair()?;
|
||||
let (mut a, mut b) = UnixStream::pair()?;
|
||||
|
||||
let (mut a_read, mut a_write) = a.split();
|
||||
let (mut b_read, mut b_write) = b.split_mut();
|
||||
let (mut b_read, mut b_write) = b.split();
|
||||
|
||||
let (a_response, b_response) = futures::future::try_join(
|
||||
send_recv_all(&mut a_read, &mut a_write, b"A"),
|
||||
|
||||
Reference in New Issue
Block a user