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

allow definition of pub struct via mock_trait #6

Merged
merged 1 commit into from
Aug 3, 2017

Conversation

hobofan
Copy link
Contributor

@hobofan hobofan commented Aug 3, 2017

This change allows you to define mock structs with pub visibility, which is nice if you want to centrally define a mock struct to be reused in many tests.

It looks like this:

   mock_trait!(
        pub MockStruct,
        somefunction(String) -> String
    );

Sadly the implementation for this involves a lot of duplicate code, but accoring to rust-lang/rust#18317 (comment) and other things I've found, there doesn't seem to be another way to do that.

@DonaldWhyte
Copy link
Owner

LGTM. Yeah, it's a shame that there is currently no 0-or-1 operator in macro definitions. That would remove the duplicate code. I've added an issue to remove this duplicate when the relevant changes have been pushed to stable Rust. The issue is here:

#7

@DonaldWhyte DonaldWhyte merged commit 6c22eaa into DonaldWhyte:master Aug 3, 2017
@DonaldWhyte
Copy link
Owner

I'll publish a new version of the double crate this evening (UK time).

@DonaldWhyte
Copy link
Owner

Published version 0.1.4 to Cargo, which should contain this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants