about summary refs log tree commit diff
path: root/src/test/incremental/thinlto
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-21 11:26:57 +0200
committerGitHub <noreply@github.com>2016-07-21 11:26:57 +0200
commitbcbe27cbf9d1e476624a9d7b18bd0228980197c7 (patch)
treeead2218c4872339213c8eedaabc76bd910045cb3 /src/test/incremental/thinlto
parente7c822cee29b5b939340c2cb0dfefa9a49742d77 (diff)
parentfbfee42a2f65b7a3d4acd0d9d029bb75208ac800 (diff)
downloadrust-bcbe27cbf9d1e476624a9d7b18bd0228980197c7.tar.gz
rust-bcbe27cbf9d1e476624a9d7b18bd0228980197c7.zip
Rollup merge of #34828 - seanmonstar:into-opton, r=alexcrichton
core: impl From<T> for Option<T>

First, the semantics of this `impl` seem spot on. If I have a value `T`, and I wish to make a `Option<T>`, then `Option::from(val)` should always give `Some(val)`.

Second, this allows improvement for several APIs that currently take `Option<T>` as arguments. Consider:

```rust
fn set_read_timeout(&mut self, timeout: Option<u32>) {
    // ...
}

x.set_read_timeout(Some(30));
x.set_read_timeout(Some(10));
x.set_read_timeout(None);
```

With this `impl`:

```rust
fn set_read_timeout<T: Into<Option<u32>>>(&mut self, timeout: T) {
    let timeout = timeout.into();
    // ...
}

x.set_read_timeout(30);
x.set_read_timeout(10);
x.set_read_timeout(Some(10)); // backwards compatible
x.set_read_timeout(None);
```

The change to those methods aren't included, but could be modified later.

r? @sfackler
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions