blob: ba9f05c64e44233b3b982e8d22b3faa25787dda2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// run-pass
#![allow(unused_imports)]
// Test a regression found when building compiler. The `produce()`
// error type `T` winds up getting unified with result of `x.parse()`;
// the type of the closure given to `unwrap_or_else` needs to be
// inferred to `usize`.
use std::num::ParseIntError;
fn produce<T>() -> Result<&'static str, T> {
Ok("22")
}
fn main() {
let x: usize = produce()
.and_then(|x| x.parse())
.unwrap_or_else(|_| panic!());
println!("{}", x);
}
|