()
| 1791 | |
| 1792 | #[test] |
| 1793 | fn result_ok_and_err_dispatch() { |
| 1794 | // Result<i32, i32> returned from a function and matched at the call site. |
| 1795 | assert_exit( |
| 1796 | r#" |
| 1797 | parse: (n: i32) -> Result<i32, i32> { |
| 1798 | if n < 0 { |
| 1799 | return Err(n) |
| 1800 | } |
| 1801 | return Ok(n * 2) |
| 1802 | } |
| 1803 | |
| 1804 | main: () -> i32 { |
| 1805 | r: Result<i32, i32> = parse(21) |
| 1806 | match r { |
| 1807 | Ok(v) -> { |
| 1808 | return v |
| 1809 | } |
| 1810 | Err(e) -> { |
| 1811 | return e |
| 1812 | } |
| 1813 | } |
| 1814 | return -1 |
| 1815 | } |
| 1816 | "#, |
| 1817 | 42, |
| 1818 | ); |
nothing calls this directly
no test coverage detected