1分钟内可阅读完
原文链接: https://book.async.rs/patterns/small-patterns.html
一系列简短、实用的模式集合。
async-std 并未在 io 句柄上提供 split() 方法。将流拆分为读端和写端可以这样做:
async-std
io
split()
1 2 3 4 5 6
# extern crate async_std; use async_std::{io, net::TcpStream}; async fn echo(stream: TcpStream) { let (reader, writer) = &mut (&stream, &stream); io::copy(reader, writer).await; }