blob: 6de25996bedd6a4f594fc3fdc41f9b2141a3ffac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// compile-flags:--test
/// ```rust,edition2018
/// #![feature(try_blocks)]
///
/// use std::num::ParseIntError;
///
/// let result: Result<i32, ParseIntError> = try {
/// "1".parse::<i32>()?
/// + "2".parse::<i32>()?
/// + "3".parse::<i32>()?
/// };
/// assert_eq!(result, Ok(6));
///
/// let result: Result<i32, ParseIntError> = try {
/// "1".parse::<i32>()?
/// + "foo".parse::<i32>()?
/// + "3".parse::<i32>()?
/// };
/// assert!(result.is_err());
/// ```
/// ```rust,edition2015,compile_fail,E0574
/// #![feature(try_blocks)]
///
/// use std::num::ParseIntError;
///
/// let result: Result<i32, ParseIntError> = try {
/// "1".parse::<i32>()?
/// + "2".parse::<i32>()?
/// + "3".parse::<i32>()?
/// };
/// assert_eq!(result, Ok(6));
///
/// let result: Result<i32, ParseIntError> = try {
/// "1".parse::<i32>()?
/// + "foo".parse::<i32>()?
/// + "3".parse::<i32>()?
/// };
/// assert!(result.is_err());
/// ```
pub fn foo() {}
|