Closed lauti7 closed 11 months ago
š¤¦š¾ this is due to me doing a very silly check when trying to check if the returned type includes the mocked struct: https://github.com/nrxus/faux/blob/709e053cc151bd8fa82578f1b28497ed26dbb1e1/faux_macros/src/methods/morphed.rs#L255-L262
This checks if any part of the return type includes the word "Self" or the name as the struct. In this case the return type Result<(), RedisError>
includes the name of the struct Redis
so faux
gets confused and thinks that this return type is special and then eventually breaks when trying to figure out how to convert into the actual return type.
I will try to get a fix out in the coming days for this but in the meantime a type alias somewhere in the module should fix this.
type MyError = RedisError
and then in the function signature -> Result<(), MyError>
.
Same behavior with an -> Option<...>
return type
@nrxus Great! Thx for the quick response. I've implemented another workaround and combined two methods in one, but your workaround is much better.
I don't close the issue so that you can close it when submitting the fix! Thx again!
@nrxus Any news regarding the fix?
@schneidersteve I've unfortunately been too swamped between work and life to take a stab at a fix yet. I am hoping to come back to faux soon since there are quite a few improvements I want to make including this fix. In the meantime though, I am always open for PRs š
Fixed in https://github.com/nrxus/faux/commit/6aa254acc217fc73feb19630a47c3f16e1efd824 which I just released as v0.1.10.
Hopefully this addresses the issues but please let me know if something is still wonky.
Hi! Ive been implementing faux to mock some structs but I'm stuck in an error that i can not work it out. Hope you can help me out with this. The issue is that the compiler is throwing an error due to the return type. The error is below:
the return type refers to the mocked struct in a way that faux cannot handle. Split this function into an
implblock not marked by #[faux::methods]. If you believe this is a mistake or it's a case that should be handled by faux please file an issue
Here below is the code. The issue is on
Redis::run
function but this function doesn't return a type that refers to the mocked struct, it just returns()
:That's all, hope you can help me.