Why do try!() and ? not compile when used in a function that doesn't return Option or Result?

后端 未结 4 1300
礼貌的吻别
礼貌的吻别 2020-11-22 06:18

Why does this code not compile?

use std::{fs, path::Path};

fn main() {
    let dir = Path::new(\"../FileSystem\");

    if !dir.is_dir() {
        println!(         


        
4条回答
  •  不知归路
    2020-11-22 07:07

    The ques_in_main RFC got merged recently. Once it's completed, the syntax in the question will indeed compile just fine and work as intended, provided the try!() calls are replaced with the ? operator.

提交回复
热议问题