Rust 程序设计语言 简体中文版 1.85.0
Compiling error-handling v0.1.0 (file:///projects/error-handling) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.73s Running `target/debug/error-handling` thread 'main' panicked main 函数的返回类型是 () 而不是 Result。当编译这些代码,会得到如下错误信息: $ cargo run Compiling error-handling v0.1.0 (file:///projects/error-handling) error[E0277]: the `?` operator can only be used in a function that returns information about this error, try `rustc --explain E0277`. error: could not compile `error-handling` (bin "error-handling") due to 1 previous error 这个错误指出只能在返回 Result、Option 或者其它实现了 FromResidual 的类型的函数中使用0 码力 | 562 页 | 3.23 MB | 8 天前3
共 1 条
- 1