thread ‘main‘ panicked at ‘called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound

2023-10-30

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "系统找不到指定的文件。" }', src\main.rs:31:55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\hello.exe` (exit code: 101)

对应的 src\main.rs:31:55 代码

        let status_line = "HTTP/1.1 404 NOT FOUND\r\n\r\n";
        let contents = fs::read_to_string("404.html").unwrap();

原因是没有找到404.html路径
rust默认是项目下,而我放在了src下
在这里插入图片描述

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

thread ‘main‘ panicked at ‘called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound 的相关文章

随机推荐