问题描述
我有一个返回 Result
的函数,我正在对它使用 ?
操作。有什么收获?
功能:
pub fn open(filename: &str) -> Result<Box<TIFF>> {
let tiff_reader = TIFFReader;
tiff_reader.load(filename)
}
MRE:
use geotiff::TIFF;
fn main() {
let res = TIFF::open("geotiff.tif")?;
println!("Hello,world!");
}
编译器:
the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
cannot use the `?` operator in a function that returns `()`
help: the trait `std::ops::Try` is not implemented for `()`
note: required by `std::ops::Try::from_error`rustc(E0277)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)