Help passing closure as argument

I'm trying to pass a closure to a function, and am struggling to get it to compile - I've tried lots of different things, but the furthest I've gotten is a single error about missing type annotations.

I've managed to reduce my issue down to a simple example - any help would be appreciated!

Try this.

You can call backoff like this: <Self as Connection>::backoff

Then you have a problem of using FnOnce inside a loop. I changed it to FnMut, but it could easily be Fn as well.


also Self::backoff() works

1 Like

Great, thanks. Can't believe I didn't think of trying Self::!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.