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

Write (at least) type signatures of placeholder functions in docs #13423

Closed
huonw opened this issue Apr 9, 2014 · 6 comments
Closed

Write (at least) type signatures of placeholder functions in docs #13423

huonw opened this issue Apr 9, 2014 · 6 comments

Comments

@huonw
Copy link
Member

huonw commented Apr 9, 2014

E.g. TcpListener has

use std::io::net::tcp::TcpListener;
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::io::{Acceptor, Listener};

let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 80 };
let listener = TcpListener::bind(addr);

// bind the listener to the specified address
let mut acceptor = listener.listen();

// accept connections and process them
for stream in acceptor.incoming() {
    spawn(proc() {
        handle_client(stream);
    });
}

// close the socket server
drop(acceptor);

but the handle_client function isn't defined, and it's not particularly obvious what it should be, having something like

fn handle_client(mut stream: TcpStream) {
     // ...
}

in the code too would make it easier to interpret. (I'm sure this isn't the only example of this.)

@huonw huonw added the A-docs label Apr 9, 2014
@ghost
Copy link

ghost commented Apr 11, 2014

Prevents errors

for stream in acceptor.incoming() {
     match stream {
          Err(_) => continue,
          Ok(socket) => spawn(proc() { handle_client(socket); }
     }
}

huonw added a commit to huonw/rust that referenced this issue Apr 11, 2014
Someone reading the docs won't know what the types of various things
are, so this adds them in a few meaningful places to help with
comprehension.

cc rust-lang#13423.
bors added a commit that referenced this issue Apr 11, 2014
Add more type signatures to the docs; tweak a few of them.

Someone reading the docs won't know what the types of various things
are, so this adds them in a few meaningful places to help with
comprehension.

cc #13423.
@ghost
Copy link

ghost commented Apr 18, 2014

Example extra (HTTP Server): https://gist.github.com/IrvMG/10617371

@steveklabnik
Copy link
Member

@huonw given that your PR in this specific case got merged, is this still valid? I mean, there may be other cases, but how will we know when this issue is done?

@huonw
Copy link
Member Author

huonw commented Aug 4, 2014

Maybe we could just do a quick pass over the docs to try to remove any remaining current instances (e.g. git grep '# .*fn' would probably pick up most instances).

@steveklabnik
Copy link
Member

👍

@steveklabnik
Copy link
Member

$ git grep "# .*fn" | wc -l
368

Whew!

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 16, 2015
I searched for times when we were hiding functions with # in the documentation,
and fixed them to not use it unless neccesary.

I also made random improvements whenever I changed something. For example,
I changed Example to Examples, for consistency.

Fixes rust-lang#13423
compiler-errors pushed a commit to compiler-errors/rust that referenced this issue Oct 26, 2022
Substitute some VSCode variables in the VSCode client

cc rust-lang/rust-analyzer#13405
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 a pull request may close this issue.

2 participants