I have tried to reproduce the problem in a very tiny program (you can find it here Rust REPL)
#[macro_use]
extern crate quick_error;
quick_error! {
#[derive(Debug)]
pub enum Error {
SomeError{
description("SomeError")
}
}
}
pub struct Version {
foo: u8,
}
pub struct Bar();
impl Bar {
pub fn version() -> Result<Version, Error> {
Ok(Version{foo: 1})
}
}
fn main() {
let tmp = Bar::version()?;
}
when trying to compile, I get the following:
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> src/main.rs:27:15
|
27 | let tmp = Bar::version()?;
| ^^^^^^^^^^^^^^^ cannot use the `?` operator in a function that returns `()`
HOWEVER, version is returning Result<Version, Error>
. What is going on?