diff options
| author | bors <bors@rust-lang.org> | 2016-11-01 03:53:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-01 03:53:42 -0700 |
| commit | ac968c466451cb9aafd9e8598ddb396ed0e6fe31 (patch) | |
| tree | c8876882be5803e7bf2074c50e22f53c34faa0eb /src/libcoretest | |
| parent | 73f5cad6c436bb3fdf460d9671d92d1133c614a2 (diff) | |
| parent | 5d31a818df97e8a71545e5ba6de0627abb7837ee (diff) | |
| download | rust-ac968c466451cb9aafd9e8598ddb396ed0e6fe31.tar.gz rust-ac968c466451cb9aafd9e8598ddb396ed0e6fe31.zip | |
Auto merge of #37299 - devonhollowood:result-unwrap-or-default, r=alexcrichton
Add `unwrap_or_default` method to `Result` Fixes #37025
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/lib.rs | 1 | ||||
| -rw-r--r-- | src/libcoretest/result.rs | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 590bf478aa7..cdbc2147318 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -34,6 +34,7 @@ #![feature(unique)] #![feature(iter_max_by)] #![feature(iter_min_by)] +#![feature(result_unwrap_or_default)] extern crate core; extern crate test; diff --git a/src/libcoretest/result.rs b/src/libcoretest/result.rs index 6e9f653dcd8..bc2cd8bbfc6 100644 --- a/src/libcoretest/result.rs +++ b/src/libcoretest/result.rs @@ -183,3 +183,9 @@ pub fn test_iter_mut() { } assert_eq!(err, Err("error")); } + +#[test] +pub fn test_unwrap_or_default() { + assert_eq!(op1().unwrap_or_default(), 666); + assert_eq!(op2().unwrap_or_default(), 0); +} |
