Update example code in documentation
thatdevsherry opened this issue · comments
The code in the first example
#[cfg(not(test))]
let url = "https://api.twitter.com";
gives a compiler error expected item after attributes
(also raised in issue #122 ).
I fixed it by replacing the let
statement with a const
one. If this is the right way to do it, the documentation should be updated with the correct code.
@Shehriyarqureshi thanks for reporting this. I updated the documentation by adding an explicit fn main { ... }
around the code: 9f74586
do note that Rust wraps doc tests inside fn main { ... }
by default so that's kind of implied when reading Rust docs (except when there is an explicit fn main {}
call). that's also why my doc tests would pass with this code.
in any case, you are still free to move these declarations outside of fn main { ... }
or simply pass mockito::server_url()
to your client during tests (if your client exposes a method to set the base URL).