📜  try and catch in rust - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:35.455000             🧑  作者: Mango

代码示例1
fn main() {
    let do_steps = || -> Result<(), MyError> {
        do_step_1()?;
        do_step_2()?;
        do_step_3()?;
        Ok(())
    };

    if let Err(_err) = do_steps() {
        println!("Failed to perform necessary steps");
    }
}