#![feature(stmt_expr_attributes, proc_macro_hygiene)] use iex::{iex, Outcome}; #[iex] fn example() -> Result { let checked_divide = { #[iex] |a: u32, b: u32| -> Result { if b == 0 { Err("Cannot divide by zero") } else { Ok(a / b) } } }; checked_divide(246, 2) } #[test] fn closure() { assert_eq!(example().into_result(), Ok(123)); }