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

"Mock" is prefixed even when using mock! #331

Open
garrettmaring opened this issue Sep 5, 2021 · 2 comments
Open

"Mock" is prefixed even when using mock! #331

garrettmaring opened this issue Sep 5, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@garrettmaring
Copy link

in the automock! documentation it is suggested to use mock! if "the autogenerated “MockFoo” name isn’t acceptable, and you want to choose your own name for the mock structure."

however, when I use mock! { pub MyStruct {} } i received an undeclared variable when trying to read MyStruct but it works when I change my import to use MockMyStruct.

how can I determine the name of the mocked structure using mock!?

@asomers
Copy link
Owner

asomers commented Sep 5, 2021

You're right; you can't. mock! is designed to allow as closely as possible copy/pasting the original struct's definition. That's why it prefixes the "Mock". Do you have a good suggestion for a syntax for an enhancement that would disable the automatic prefix?

@asomers asomers added the enhancement New feature or request label Sep 5, 2021
@garrettmaring
Copy link
Author

garrettmaring commented Sep 5, 2021

hm, is mock!(prefix = "") or mock!(disable-prefix) the simplest possibilities?

i'm also reminded of serde's renaming #[serde(rename = "MyRename")] which could lead to something similar that might go inside mock! above the struct definition.

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

No branches or pull requests

2 participants