Skip to content

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

Closed
@huonw

Description

@huonw

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions