Skip to content

mutable borrow of TcpStream inside select! #3740

Discussion options

You must be logged in to vote

OK, I solved this problem by splitting the stream in two parts: a reader and a writer. Then, I edited the receive() function to take ownership of the reader and return it at the end, alongside the buffer. receive_operation is now declared like that:

let receive_operation = receive(reader);

That way, I have a mutable reference to writer everywhere in the loop and ownership of reader in the first select! branch so I can call receive_operation.set(receive(reader)).

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hardcore-sushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant