vthread 0.0.1

Bounded carrier-affine virtual threads for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::{Error, Runtime, net::TcpStream};

#[test]
fn refused_connect_returns_the_socket_error_instead_of_successful_readiness() {
    let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
    let address = listener.local_addr().unwrap();
    drop(listener);
    Runtime::new()
        .unwrap()
        .run_scope(|scope| {
            let mut task = scope.spawn("refused", move || TcpStream::connect(address))?;
            assert!(matches!(task.join()?, Err(Error::Io(_))));
            Ok(())
        })
        .unwrap();
}