It's easy to forget to mount a mock to a server, even though the docs call this out. This commit tags the Mock struct with #[must_use], so that Rust itself can warn users when they forget to mount their mocks. The help string
Here's the warning emitted:
warning: unused `Mock` that must be used
--> examples\must_use.rs:9:5
|
9 | Mock::given(method("GET")).respond_with(response.clone());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `Mock`s have to be mounted or registered with a `MockServer` to become effective
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
9 | let _ = Mock::given(method("GET")).respond_with(response.clone());
| +++++++
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Description of changes:
It's easy to forget to mount a mock to a server, even though the docs call this out. This commit tags the
Mock
struct with#[must_use]
, so that Rust itself can warn users when they forget to mount their mocks. The help stringHere's the warning emitted:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.