You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @asomers ! I'm not sure how best to reach you, so I figured I'd open an issue. I'm curious to talk over what are some of the technical blockers you've encountered in authoring mockall, and what it would take to overcome them. For example, I'd like to make sure mockall can support async fns in traits once they're stabilized, and I'd also like to lift the limitations about lifetime vs generic parameters.
The text was updated successfully, but these errors were encountered:
Hi Niko! I'm glad to see your interest. And yes, the language presented several challenges while writing this crate. You're right that lifetimes are the biggest limitations. Mockall can't use non-'static generic arguments as function arguments because the matching functions must be downcast to Any (#217). See also https://internals.rust-lang.org/t/hrtbs-for-unspecified-lifetimes/14868 for a discussion of a new language feature that could solve the problem.
async functions in traits aren't really a problem. After all, Mockall already works with the #[async_trait] crate.
Another problem is the inability for a proc macro to operate on multiple items. If it could, then #[automock] could be used much more widely, such as to mock structs with multiple trait impls. See https://users.rust-lang.org/t/how-to-pass-multiple-items-to-a-derive-macro/91266 . If this were solved, the Mockall would be much easier to use, since mock! could be eliminated for most cases. Also, attribute tags like #[concretize] could be implemented in a less-hacky way. There have been several other proposals for such attribute tags that I've held off from implementing because there's no good way to do it now.
Repository owner
locked and limited conversation to collaborators
May 13, 2023
Hi @asomers ! I'm not sure how best to reach you, so I figured I'd open an issue. I'm curious to talk over what are some of the technical blockers you've encountered in authoring mockall, and what it would take to overcome them. For example, I'd like to make sure mockall can support async fns in traits once they're stabilized, and I'd also like to lift the limitations about lifetime vs generic parameters.
The text was updated successfully, but these errors were encountered: