Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[net] add explicit lifetime to tcp socket split() function #3736

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

siemtim-dev
Copy link

I added explicit lifetimes to the TcpSocket::split() function.

old version:

    pub fn split(&mut self) -> (TcpReader<'_>, TcpWriter<'_>) {
        (TcpReader { io: self.io }, TcpWriter { io: self.io })
    }

In the old version the lifetime of the TcpReader and TcpWriter seems to be the lifetime of &mut self. By adding explicit lifetimes users of this function have more flexibility.

What do you think about this change?

@Dirbaio
Copy link
Member

Dirbaio commented Jan 7, 2025

this would allow multiple writers or readers existing for the same socket at the same time. The current signature of split() is intentionally designed to avoid this.

What are you trying to do that requires this change? maybe there's an alternate way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants