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