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

clarify documentation of TcpStream::connect() for multiple valid addresses #33167

Merged
merged 1 commit into from
Apr 26, 2016

Conversation

benaryorg
Copy link
Contributor

I am not sure how the UDP part of the stdlib behaves when passing multiple valid addresses, but it should be mentioned as there are legit use cases for impl<'a> ToSocketAddrs for &'a [SocketAddr], a TCP fallback only being one.

Just a little example program for anyone willing to enhance the documentation further:

use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::net::TcpStream;

fn main()
{
    let v: Vec<SocketAddr> = vec!
    [
        "127.0.0.1:1338".to_socket_addrs().unwrap().next().unwrap(),
        "127.0.0.1:1337".to_socket_addrs().unwrap().next().unwrap(),
        "127.0.0.1:1339".to_socket_addrs().unwrap().next().unwrap(),
    ];

    let stream = TcpStream::connect(&v[..]).unwrap();
}

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@alexcrichton
Copy link
Member

@bors: r+ 68a18c4 rollup

Thanks!

@bors
Copy link
Contributor

bors commented Apr 24, 2016

⌛ Testing commit 68a18c4 with merge 061cff6...

@bors
Copy link
Contributor

bors commented Apr 24, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@alexcrichton
Copy link
Member

@bors: retry

On Sun, Apr 24, 2016 at 4:46 AM, bors [email protected] wrote:

[image: 💔] Test failed - auto-win-msvc-64-cargotest
http://buildbot.rust-lang.org/builders/auto-win-msvc-64-cargotest/builds/225


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#33167 (comment)

Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 25, 2016
clarify documentation of TcpStream::connect() for multiple valid addresses

I am not sure how the UDP part of the stdlib behaves when passing multiple valid addresses, but it should be mentioned as there are legit use cases for [`impl<'a> ToSocketAddrs for &'a [SocketAddr]`](http://doc.rust-lang.org/nightly/std/net/trait.ToSocketAddrs.html), a TCP fallback only being one.

Just a little example program for anyone willing to enhance the documentation further:

```rust
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::net::TcpStream;

fn main()
{
	let v: Vec<SocketAddr> = vec!
	[
		"127.0.0.1:1338".to_socket_addrs().unwrap().next().unwrap(),
		"127.0.0.1:1337".to_socket_addrs().unwrap().next().unwrap(),
		"127.0.0.1:1339".to_socket_addrs().unwrap().next().unwrap(),
	];

	let stream = TcpStream::connect(&v[..]).unwrap();
}
```
bors added a commit that referenced this pull request Apr 25, 2016
Rollup of 7 pull requests

- Successful merges: #33107, #33133, #33160, #33167, #33194, #33196, #33200
- Failed merges:
bors added a commit that referenced this pull request Apr 26, 2016
Rollup of 7 pull requests

- Successful merges: #33107, #33133, #33160, #33167, #33194, #33196, #33200
- Failed merges:
@bors bors merged commit 68a18c4 into rust-lang:master Apr 26, 2016
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 this pull request may close these issues.

5 participants