Skip to content

Fix docs for UdpSocket::send #671

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

Merged
merged 3 commits into from
Jan 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/net/udp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,12 @@ impl UdpSocket {
}))
}

/// Sends data on the socket to the given address.
/// Sends data on the socket to the remote address to which it is connected.
///
/// On success, returns the number of bytes written.
/// The [`connect`] method will connect this socket to a remote address.
/// This method will fail if the socket is not connected.
///
/// [`connect`]: #method.connect
///
/// # Examples
///
Expand Down Expand Up @@ -297,12 +300,11 @@ impl UdpSocket {
/// #
/// use async_std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:0").await?;
/// let socket = UdpSocket::bind("127.0.0.1:7878").await?;
/// socket.connect("127.0.0.1:8080").await?;
/// let bytes = socket.send(b"Hi there!").await?;
///
/// let mut buf = vec![0; 1024];
/// let n = socket.recv(&mut buf).await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove recv call?
Is this an example of the recv function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It looks like I put the docs in the wrong spot. I'll correct that issue right now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it

/// println!("Received {} bytes", n);
/// println!("Sent {} bytes", bytes);
/// #
/// # Ok(()) }) }
/// ```
Expand Down