Fix compiler error about callback lifetime

This fixes a compiler error I got after upgrading to the latest Rust version. The commit message contains details about the error.

Please review this extra-carefully. I think I understand what I did there, but I'm not 100% sure :)
I'm especially not sure, if this is the cleanest way to do this.

Anyway, I've tested the examples, and they all still work, as far as I can tell.