Skip to content

How to handle lifetimes within mock! block? #293

Answered by asomers
mknet asked this question in Questions
Discussion options

You must be logged in to vote

LOL, what timing! The easiest course of action for you would be to upgrade Mockall to the latest version in git. As of yesterday, it will automatically generate a Debug impl.
But if you don't want to do that, then write the function signature like this. I think all three of these forms will work:

  • pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
  • pub fn fmt<'a>(&self, f: &mut Formatter<'a>) -> Result<(), Error>;
  • pub fn fmt(&self, f: &mut Formatter -> Result<(), Error>;

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mknet
Comment options

Answer selected by asomers
Comment options

You must be logged in to vote
1 reply
@mknet
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usage question
2 participants
Converted from issue

This discussion was converted from issue #291 on June 21, 2021 21:50.