3

I want to mock a regular single method in the module scope (not a trait or struct method), that will return a constant value, but I can't find any example in the docs.

Shepmaster
  • 326,504
  • 69
  • 892
  • 1,159
Eyal leshem
  • 874
  • 2
  • 9
  • 19
  • that the closet thing to mock that i found until now : https://klau.si/blog/mocking-in-rust-with-conditional-compilation/ – Eyal leshem Jan 04 '20 at 18:20

1 Answers1

4

The short answer is no, but the workarounds are pretty easy: 1) Turn your single free function into a static method of a struct, and mock the struct. 2) Put your single free function into a module, and mock the module (requires nightly).