<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/libstd/net, branch stable</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=stable</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=stable'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2020-07-28T00:51:13+00:00</updated>
<entry>
<title>mv std libs to library/</title>
<updated>2020-07-28T00:51:13+00:00</updated>
<author>
<name>mark</name>
<email>markm@cs.wisc.edu</email>
</author>
<published>2020-06-12T02:31:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2c31b45ae878b821975c4ebd94cc1e49f6073fd0'/>
<id>urn:sha1:2c31b45ae878b821975c4ebd94cc1e49f6073fd0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]</title>
<updated>2020-07-02T06:03:37+00:00</updated>
<author>
<name>Yashhwanth Ram</name>
<email>ryr397@gmail.com</email>
</author>
<published>2020-07-02T06:03:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8dc1e42515adbf0946a235b464b2fd41619cec04'/>
<id>urn:sha1:8dc1e42515adbf0946a235b464b2fd41619cec04</id>
<content type='text'>
Enclose unsafe operations in unsafe blocks
</content>
</entry>
<entry>
<title>Rollup merge of #72369 - Lucretiel:socketaddr-parse, r=dtolnay</title>
<updated>2020-07-01T14:42:32+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-01T14:42:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=33f8ce287a62d8c76c7cea11c5cf67f53d5b8f40'/>
<id>urn:sha1:33f8ce287a62d8c76c7cea11c5cf67f53d5b8f40</id>
<content type='text'>
Bring net/parser.rs up to modern up to date with modern rust patterns

The current implementation of IP address parsing is very unidiomatic; it's full of `if` / `return` / `is_some` / `is_none` instead of `?`, `loop` with manual index tracking; etc. Went through and did and cleanup to try to bring it in line with modern sensibilities.

The obvious concern with making changes like this is "make sure you understand why it's written that way before changing it". Looking through the commit history for this file, there are several much smaller commits that make similar changes (For instance, https://github.com/rust-lang/rust/commit/3024c1434a667425d30e4b0785857381323712aa, https://github.com/rust-lang/rust/commit/4f3ab4986ec96d9c93f34dc53d0a4a1279288451, https://github.com/rust-lang/rust/commit/79f876495b2853d1b78ba953ceb3114b8019100f), and there don't seem to be any commits in the history that indicate that this lack of idiomaticity is related to specific performance needs (ie, there aren't any commits that replace a `for` loop with a `loop` and a manual index count). In fact, the basic shape of the file is essentially unchanged from its initial commit back in 2015.

Made the following changes throughout the IP address parser:
- Replaced all uses of `is_some()` / `is_none()` with `?`.
- "Upgraded" loops wherever possible; ie, replace `while` with `for`, etc.
    - Removed all cases of manual index tracking / incrementing.
- Renamed several single-character variables with more expressive names.
- Replaced several manual control flow segments with equivalent adapters (such as `Option::filter`).
- Removed `read_seq_3`; replaced with simple sequences of `?`.
- Parser now reslices its state when consuming, rather than carrying a separate state and index variable.
- `read_digit` now uses `char::to_digit`.
- Added comments throughout, especially in the complex IPv6 parsing logic.
- Added comprehensive local unit tests for the parser to validate these changes.
</content>
</entry>
<entry>
<title>Bring net/parser.rs up to modern up to date with modern rust patterns</title>
<updated>2020-06-30T18:44:14+00:00</updated>
<author>
<name>Nathan West</name>
<email>Lucretiel@gmail.com</email>
</author>
<published>2020-05-20T03:26:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3ab7ae39ec77a39df27ac6c3fbde03cd3b763542'/>
<id>urn:sha1:3ab7ae39ec77a39df27ac6c3fbde03cd3b763542</id>
<content type='text'>
Made the following changes throughout the IP address parser:
- Replaced all uses of `is_some()` / `is_none()` with `?`.
- "Upgraded" loops wherever possible; ie, replace `while` with `for`, etc.
    - Removed all cases of manual index tracking / incrementing.
- Renamed several single-character variables with more expressive names.
- Replaced several manual control flow segments with equivalent adapters (such as `Option::filter`).
- Removed `read_seq_3`; replaced with simple sequences of `?`.
- Parser now reslices its state when consuming, rather than carrying a separate state and index variable.
- `read_digit` now uses `char::to_digit`.
- Removed unnecessary casts back and forth between u8 and u32
- Added comments throughout, especially in the complex IPv6 parsing logic.
- Added comprehensive local unit tests for the parser to validate these changes.
</content>
</entry>
<entry>
<title>Auto merge of #73007 - yoshuawuyts:socketaddr-from-string-u16, r=sfackler</title>
<updated>2020-06-23T00:13:50+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2020-06-23T00:13:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=dcd470fe1be03136a8e1794b7e2cc6179bbd9d92'/>
<id>urn:sha1:dcd470fe1be03136a8e1794b7e2cc6179bbd9d92</id>
<content type='text'>
impl ToSocketAddrs for (String, u16)

This adds a convenience impl of `ToSocketAddrs for (String, u16)`. When authoring HTTP services it's common to take command line options for `host` and `port` and parse them into `String` and `u16` respectively. Consider the following program:
```rust
#[derive(Debug, StructOpt)]
struct Config {
    host: String,
    port: u16,
}

async fn main() -&gt; io::Result&lt;()&gt; {
    let config = Config::from_args();
    let stream = TcpStream::connect((&amp;*config.host, config.port))?; // &amp;* is not ideal
    // ...
}
```

Networking is a pretty common starting point for people new to Rust, and seeing `&amp;*` in basic examples can be confusing. Even as someone that has experience with networking in Rust I tend to forget that `String` can't be passed directly there. Instead with this patch we can omit the `&amp;*` conversion and pass `host` directly:
```rust
#[derive(Debug, StructOpt)]
struct Config {
    host: String,
    port: u16,
}

async fn main() -&gt; io::Result&lt;()&gt; {
    let config = Config::from_args();
    let stream = TcpStream::connect((config.host, config.port))?; // no more conversions!
    // ...
}
```

I think should be an easy and small ergonomics improvement for networking. Thanks!
</content>
</entry>
<entry>
<title>Add test for comparing SocketAddr with inferred right-hand side</title>
<updated>2020-06-13T17:21:11+00:00</updated>
<author>
<name>David Tolnay</name>
<email>dtolnay@gmail.com</email>
</author>
<published>2020-06-13T17:21:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=204c236ad5b632294d8794e729326be8053ab2aa'/>
<id>urn:sha1:204c236ad5b632294d8794e729326be8053ab2aa</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Revert heterogeneous SocketAddr PartialEq impls</title>
<updated>2020-06-13T05:13:55+00:00</updated>
<author>
<name>David Tolnay</name>
<email>dtolnay@gmail.com</email>
</author>
<published>2020-06-13T05:12:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c45231ca555950cea450ba65f9d2d1962e3af6cd'/>
<id>urn:sha1:c45231ca555950cea450ba65f9d2d1962e3af6cd</id>
<content type='text'>
These lead to inference regressions (mostly in tests) in code that looks
like:

    let socket = std::net::SocketAddrV4::new(std::net::Ipv4Addr::new(127, 0, 0, 1), 8080);
    assert_eq!(socket, "127.0.0.1:8080".parse().unwrap());

That compiles as of stable 1.44.0 but fails in beta with:

    error[E0284]: type annotations needed
     --&gt; src/main.rs:3:41
      |
    3 |     assert_eq!(socket, "127.0.0.1:8080".parse().unwrap());
      |                                         ^^^^^ cannot infer type for type parameter `F` declared on the associated function `parse`
      |
      = note: cannot satisfy `&lt;_ as std::str::FromStr&gt;::Err == _`
    help: consider specifying the type argument in the method call
      |
    3 |     assert_eq!(socket, "127.0.0.1:8080".parse::&lt;F&gt;().unwrap());
      |
</content>
</entry>
<entry>
<title>impl ToSocketAddrs for (String, u16)</title>
<updated>2020-06-05T10:56:29+00:00</updated>
<author>
<name>Yoshua Wuyts</name>
<email>yoshuawuyts@gmail.com</email>
</author>
<published>2020-06-04T23:49:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2764e54c29d0f19242e794d5eecd00cc5470f530'/>
<id>urn:sha1:2764e54c29d0f19242e794d5eecd00cc5470f530</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJung</title>
<updated>2020-05-29T23:43:20+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2020-05-29T23:43:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=0e9e4083100aa3ebf09b8f1ace0348cb37475eb9'/>
<id>urn:sha1:0e9e4083100aa3ebf09b8f1ace0348cb37475eb9</id>
<content type='text'>
Rollup of 9 pull requests

Successful merges:

 - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes)
 - #71095 (impl From&lt;[T; N]&gt; for Box&lt;[T]&gt;)
 - #71500 (Make pointer offset methods/intrinsics const)
 - #71804 (linker: Support `-static-pie` and `-static -shared`)
 - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn)
 - #72103 (borrowck `DefId` -&gt; `LocalDefId`)
 - #72407 (Various minor improvements to Ipv6Addr::Display)
 - #72413 (impl Step for char (make Range*&lt;char&gt; iterable))
 - #72439 (NVPTX support for new asm!)

Failed merges:

r? @ghost
</content>
</entry>
<entry>
<title>Rollup merge of #72407 - Lucretiel:ipv6-display, r=Mark-Simulacrum</title>
<updated>2020-05-29T19:58:29+00:00</updated>
<author>
<name>Ralf Jung</name>
<email>post@ralfj.de</email>
</author>
<published>2020-05-29T19:58:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=de561a9d3d8d06969abc4f6851fd532f584ff52c'/>
<id>urn:sha1:de561a9d3d8d06969abc4f6851fd532f584ff52c</id>
<content type='text'>
Various minor improvements to Ipv6Addr::Display

Cleaned up `Ipv6Addr::Display`, especially with an eye towards simplifying and reducing duplicated logic. Also added a fast-path optimization, similar to #72399 and #72398.

- Defer to `Ipv4Addr::fmt` when printing an Ipv4 address
- Fast path: write directly to `f` without an intermediary buffer when there are no alignment options
- Simplify finding the inner zeroes-span
</content>
</entry>
</feed>
