Can't use the proc-macros with anyhow
oren0e opened this issue · comments
I have found this PR: #46 which was supposed to solve the issue as far as I understand, but still if I have a function that returns the anyhow::Result
I get the following errors:
error[E0308]: mismatched types
--> src/actions.rs:11:1
|
11 | #[cached]
| ^^^^^^^^^ expected enum `Result`, found reference
and
error[E0599]: the method `clone` exists for enum `Result<String, anyhow::Error>`, but its trait bounds were not satisfied
--> src/actions.rs:11:1
|
11 | #[cached]
| ^^^^^^^^^ method cannot be called on `Result<String, anyhow::Error>` due to unsatisfied trait bounds
What can I do about it?
I’m assuming you don’t want to cache the error scenario - have you tried specifying result = true
? More in the macro docs here https://docs.rs/cached/latest/cached/proc_macro/attr.cached.html
#[cached(result = true)]
Ah missed that entirely, thanks, that solved the problem!
Nice! I notice that in a recent refactor the example showing how to handle results was removed from the readme. Probably wouldn't hurt to add one back!