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

Added some examples fo mio::net::UdpSocket. #762

Merged
merged 3 commits into from Dec 15, 2017

Conversation

Projects
None yet
2 participants
@lanedraex
Copy link
Contributor

lanedraex commented Nov 16, 2017

Some rustdoc examples: (#665)

Includes examples for: UdpSocket, bind, local_addr, send_to, recv_from, set_broadcast, broadcast.

net/udp.rs added mio::net::UdpSocket examples for: UdpSocket, bind, l…
…ocal_addr, send_to, recv_from, set_broadcast, broadcast.
@carllerche

This comment has been minimized.

Copy link
Owner

carllerche commented Nov 17, 2017

Thanks for the PR!

I think including a full example for the struct level docs is probably good, however, for each individual function, would it be possible to reduce down the example to focus on the function as question? This should make it easier to see the relevant bits. Ideally, none of the fn level examples would include a full event loop.

@lanedraex

This comment has been minimized.

Copy link
Contributor Author

lanedraex commented Nov 20, 2017

Hey, should the examples hide the event loop with # or should I simply "fake" calls to the functions like:

# Ok(())
socket.send_to(&buffer, &addr);

Or something else entirely?

@carllerche
Copy link
Owner

carllerche left a comment

Woops, it seems like I never clicked "send" for this comment.

/// use mio::{Events, Ready, Poll, PollOpt, Token};
/// use std::time::Duration;
///
/// const SENDER: Token = Token(0x4c4f4f43);

This comment has been minimized.

@carllerche

carllerche Nov 20, 2017

Owner

Maybe just use 0 / 1 here? The other examples do that and I think we want to try to stick with a single style.

@carllerche

This comment has been minimized.

Copy link
Owner

carllerche commented Nov 20, 2017

@lanedraex sticking with fake calls is fine. You can use the no_run annotation I think it is.

@carllerche carllerche merged commit 90bfc7d into carllerche:master Dec 15, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@carllerche

This comment has been minimized.

Copy link
Owner

carllerche commented Dec 15, 2017

@lanedraex Thanks, these examples look great.

@lanedraex

This comment has been minimized.

Copy link
Contributor Author

lanedraex commented Dec 17, 2017

I'll add examples to the other methods.

Also, just noticed that I made a typo in the pull request title, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.