Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for non-Send types #80

Closed
1 of 2 tasks
Monnoroch opened this issue Nov 20, 2019 · 3 comments · Fixed by #178
Closed
1 of 2 tasks

Better support for non-Send types #80

Monnoroch opened this issue Nov 20, 2019 · 3 comments · Fixed by #178
Labels
enhancement New feature or request

Comments

@Monnoroch
Copy link
Contributor

Monnoroch commented Nov 20, 2019

mockall has returning_st method to return non-Send types. However, this capability is not present for other parts of the API:

  • Add return_const_st
  • Add withf_st

This is actually a bit of a pain for me currently as I'm mocking C functions that accept / return pointers. Currently I have to give up on return_const and pass pointers casted with as usize to withf, which is ugly.

@Monnoroch
Copy link
Contributor Author

I might be able to contribute, but would like to confirm that this is indeed something maintainers would like implemented.

@asomers
Copy link
Owner

asomers commented Nov 20, 2019

I don't understand why the lack of return_const_st should cause very much pain. A little bit of pain, sure. But can't you simply do returning_st(move |_| my_constant)? OTOH, I very much understand the need for withf_st. That would be an important new feature.

return_const_st could also be useful, and I would also accept it. An even cooler implementation would be to use specialization to automatically select the implementation to use, based on whether the argument is Send. However, that would require nightly.

@asomers asomers added the enhancement New feature or request label Nov 20, 2019
@Monnoroch
Copy link
Contributor Author

Fair enough, the lack of return_const_st is a little bit of pain. Still, would be nice to have.

asomers added a commit that referenced this issue Aug 23, 2020
* Added `return_const_st` for returning non-`Send` constants, similar to
  `returning_st`.

* Added `return_once_st` for static methods.  It was already available for
  non-static methods.

Fixes #80
asomers added a commit that referenced this issue Aug 23, 2020
* Added `return_const_st` for returning non-`Send` constants, similar to
  `returning_st`.

* Added `return_once_st` for static methods.  It was already available for
  non-static methods.

Fixes #80
asomers added a commit that referenced this issue Aug 23, 2020
* Added `return_const_st` for returning non-`Send` constants, similar to
  `returning_st`.

* Added `return_once_st` for static methods.  It was already available for
  non-static methods.

Fixes #80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants