I'm trying to implement a simple function that returns a generic error message.
fn unimplemented<T>() -> Result<T, String> {
let res: Result<T, String> = Err("Not implemented yet!".to_string());
res
}
(I'm aware of the unimplemented!
macro, but I don't want a panic, just a Result
)
The compiler isn't being very helpful:
error[E0282]: unable to infer enough type information about `_`
--> src\main.rs:214:9
|
214 | Err("Unimplemented");
| ^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
I cannot for the life of me find any information on this error message that is relevant to my problem, nor on type annotations in Rust in general.