Closed laumann closed 9 years ago
With these changes the example from #8 is correctly rejected.
extern crate rust_sessions;
use std::thread::spawn;
use std::sync::mpsc::channel;
use rust_sessions::*;
type Proto = Send<u8, Eps>;
fn main() {
let (tx, rx) = channel();
let guard = spawn(|| {
let c: Chan<(), Proto> = accept(tx).unwrap();
c.send(42).close();
});
let c: Chan<(), Proto> = rx.recv().ok().unwrap(); // Does not use request!!
c.send(42).close();
}
produces the following error:
examples/fail.rs:16:30: 16:53 error: mismatched types:
expected `rust_sessions::Chan<(), rust_sessions::Send<u8, rust_sessions::Eps>>`,
found `rust_sessions::Chan<(), rust_sessions::Recv<u8, rust_sessions::Eps>>`
(expected struct `rust_sessions::Send`,
found struct `rust_sessions::Recv`) [E0308]
examples/fail.rs:16 let c: Chan<(), Proto> = rx.recv().ok().unwrap();
^~~~~~~~~~~~~~~~~~~~~~~
The problem seems to be that request
was transmuting the received channel Chan<P>
. But the accept()
function should be sending the value Chan<P::Dual>
instead.
@laumann: Let's merge this?
Fixes #8