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

Working code examples for std::rt::io::net #9829

Closed
wants to merge 1 commit into from

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Oct 12, 2013

Hi!

I was trying to play with networking code today, and noticed the code example in std::rt::io was not really corresponding to TcpStream.

If that code is ok, I'll add more examples in this pull request for TcpStream and UdpStream, client and server and squash it in one commit.

BTW, it seems that std::io::{Reader,Writer} and std::rt::io::{Reader,Writer} are not consistent. These code examples would be nicer if I could use std::io::{ReaderUtil,WriterUtil}. Should I continue the work that began in #9749 to make them available in std::rt::io?

@alexcrichton
Copy link
Member

I believe that those examples were written long before the actual code was written, and it's a bit unfortunate that the actual code to perform such a simple operation is so verbose.

The runtime is still very much in flux, and I'd rather not commit to this becoming "the example" for making an HTTP request. I think that there are a few ways that this could become smaller again though:

  • There is actually a read_to_end on the ReaderUtil trait in std::rt::io::extensions
  • I don't think that this example needs to go through the rigamarole of decoding the string as utf8

Right now the priority effort is to remove std::io completely, but it is very tightly rooted in many portions of the compiler. For now we're still dealing with the string-related apis of the new runtime because it's not clear how different encodings will be handled (and they certainly should be). I would hold off on writing new *Util traits for now.

@Geal
Copy link
Contributor Author

Geal commented Oct 13, 2013

Alright. Then how can I help with removing std::io? Or are there other parts of std or extra that need code examples? (this is one of my ways of learning a new language/platform: test undocumented APIs, read source, write docs)

@alexcrichton
Copy link
Member

I definitely agree that we need more code examples, but now may not be the best time to write code examples for std::rt::io because it's still not a concrete vision to the finish line of what the apis are going to look like.

That being said, we're always more than happy to get some help! If you want to help axe std::io, that would be incredibly helpful. One of the major consumers is extra::json, and I've got an in-flight patch with an attempt to remove it. It turns out that it was incredibly deeply rooted throughout many many modules and I'm having a difficult time removing it all the way. I'm sure there's plenty of tendrils of std::io in many other locations, however, and removal of any of them would be really helpful!

@brson
Copy link
Contributor

brson commented Oct 26, 2013

OK, it sounds like the right approach here is more to meet in the middle: make I/O more ergonomic so that code can be written more like the existing examples, while beefing up the documentation to reflect the current state of I/O. Closing this, but thanks for the patch @Geal, and please do continue work on I/O and docs.

@brson brson closed this Oct 26, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 21, 2022
Make it clear that `or_fun_call` can be a false-positive

Also move it to nursery so that the false-positives can be dealt with.

CC rust-lang#8574

changelog: [`or_fun_call`]: Mention false-positives, move to nursery.
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.

3 participants