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

Use &self instead of &mut self for ReadHalf::peek #7088

Closed
wants to merge 1 commit into from

Conversation

al8n
Copy link
Contributor

@al8n al8n commented Jan 11, 2025

Hi, this PR remove the change &mut self to &self in ReadHalf::peek.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-net Module: tokio/net labels Jan 11, 2025
@Darksonn
Copy link
Contributor

This is a breaking change in the main Tokio crate. It's not going to happen.

@Darksonn Darksonn closed this Jan 11, 2025
@al8n
Copy link
Contributor Author

al8n commented Jan 11, 2025

This is a breaking change in the main Tokio crate. It's not going to happen.

But it is weird, because TcpStream::peek requires &self, but ReadHalf require &mut self

@al8n
Copy link
Contributor Author

al8n commented Jan 11, 2025

Here are the documents:

  1. TcpStream::peek: https://docs.rs/tokio/latest/tokio/net/struct.TcpStream.html#method.peek
  2. ReadHalf::peek: https://docs.rs/tokio/latest/tokio/net/tcp/struct.ReadHalf.html#method.peek
  3. OwnedReadHalf::peek: https://docs.rs/tokio/latest/tokio/net/tcp/struct.OwnedReadHalf.html#method.peek

The ReadHalf::peek and OwnedReadHalf::peek signatures differ from TcpStream::peek.

@Darksonn
Copy link
Contributor

We could fix that, but we will not because it's a breaking change. You can always call TcpStream::peek via .as_ref() since that lets you access the underlying IO resource from a read half.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-net Module: tokio/net
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants