In this case, the git2 crate (https://docs.rs/git2/) is a thin wrapping over libgit2 (https://libgit2.org). To ensure a push went through properly you have to watch what happens inside a callback. The docs state the following:
Note that you'll likely want to use RemoteCallbacks and set push_update_reference to test whether all the references were pushed successfully.
It looks like the only sensible way to utilize this is by closing over mutable state and then checking that imperatively, which is far from idiomatic (this is what they do in the patch). If you were pushing multiple refs it would be even worse!
Usually, when you use some rust code, it's pretty easy to tell what can fail simply by looking at the types - this is a huge win. Thin wrappers can subtly violate this intuition: sometimes errors are handled idiomatically and sometimes they aren't, leading to a sort of false sense of security.
The takeaway here is to use an abundance of caution when utilizing a thin wrapper and to understand just how thick it is, especially with errors.