Since Rust hasn’t yet solved these problems, I’ve extended a better solution (without closure, so no need to shut up clippy) and published it.