Crate io_arc

Source
Expand description

Proof of concept Arc with IO trait delegation

§Examples

use std::net::TcpStream;
use io_arc::IoArc;
use std::io::{self, prelude::*};

fn main() -> io::Result<()> {
    let stream = TcpStream::connect("localhost:8080")?;
    let stream = IoArc::new(stream);

    let mut stream1 = stream.clone();
    let mut _stream2 = stream.clone();

    stream1.write(b"hello world")?; // Write is implemented for Arc<TcpStream> directly
    Ok(())
}

Structs§

  • A variant of Arc that delegates IO traits if available on &T.