rust-lang / git2-rs

libgit2 bindings for Rust
https://docs.rs/git2
Apache License 2.0
1.64k stars 380 forks source link

`FnMut` type should be used with a mutable reference #970

Closed EFanZh closed 11 months ago

ehuss commented 11 months ago

Thanks, can you provide some more context on this change? What is the motivation for it?

EFanZh commented 11 months ago

Since C is of type FnMut(Oid) -> bool, calling it would require a mutable reference. Currently, with_hide_callback accepts a shared reference (&C), so theoretically, it should not able to call the function. I think this is a soundness issue, since it essentially converts &C to &mut C.