rust/library
Guillaume Gomez 6ce8a371bd
Rollup merge of #87874 - schneems:schneems/tcpstream-iterator-type, r=Mark-Simulacrum
Add TcpStream type to TcpListener::incoming docs

## Context

While going through the "The Rust Programming Language" book (Klabnik & Nichols), the TCP server example directs us to use TcpListener::incoming. I was curious how I could pass this value to a function (before reading ahead in the book), so I looked up the docs to determine the signature.

When I opened the docs, I found https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming, which didn't mention TcpStream anywhere in the example.

Eventually, I clicked on https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.accept in the docs (after clicking a few other locations first), and was able to surmise that the value contained TcpStream.

## Opportunity

While this type is mentioned several times in this doc, I feel that someone should be able to fully use the results of the TcpListner::incoming iterator based solely on the docs of just this method.

## Implementation

I took the code from the top-level TcpListener https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming and blended it with the existing docs for TcpListener::incoming https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming.

It does make the example a little longer, and it also introduces a little duplication. It also gives the reader the type signatures they need to move on to the next step.

## Additional considerations

I noticed that in this doc, `handle_connection` and `handle_client` are both used to accept a TcpStream in the docs on this page. I want to standardize on one function name convention, so readers don't accidentally think two different concepts are being referenced. I didn't want to cram do too much in one PR, I can update this PR to make that change, or I could send another PR (if you would like).

First attempted contribution to Rust (and I'm also still very new, hence reading through the rust book for the first time)! Would you please let me know what you think?
2021-08-19 19:30:05 +02:00
..
alloc Constified Default implementations 2021-08-17 07:15:54 +00:00
backtrace@221483ebaf
core Rollup merge of #88031 - ibraheemdev:build-hasher-object-safe, r=m-ou-se 2021-08-18 19:54:57 +02:00
panic_abort Use C-unwind ABI for __rust_start_panic in panic_abort 2021-08-05 18:01:17 +08:00
panic_unwind STD support for the ESP-IDF framework 2021-08-10 12:09:00 +03:00
proc_macro Change proc_macro::Diagnostics docs 2021-08-07 23:54:34 +10:00
profiler_builtins rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rtstartup
rustc-std-workspace-alloc rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc-std-workspace-core rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc-std-workspace-std rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
std Rollup merge of #87874 - schneems:schneems/tcpstream-iterator-type, r=Mark-Simulacrum 2021-08-19 19:30:05 +02:00
stdarch@c158cfd38e Update stdarch to deprecate crypto aarch64 target_feature 2021-08-03 12:07:56 +00:00
test rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
unwind STD support for the ESP-IDF framework 2021-08-10 12:09:00 +03:00