I have what I think to be a simple question, but not much luck finding an answer for it.
Background
I understand the difference between Fn
and FnMut
in Rust, but I see quite often the need to accept closures that require a 'static
lifetime bound.
The Question
Is an Fn() + 'static
equivalent to FnMut() + 'static
?
My Opinion
In my opinion, I seem to believe they are, because an Fn
allows for capturing immutable references to its environment, whereas FnMut
, mutable references, however, due to the 'static
lifetime bound, the only references they can have, are owned ones, and therefore will almost always have move semantics associated with the closure. Since only owned values, or special &'static
references can have 'static
lifetime, it seems to me pointless to want to have or need an FnMut()
in this case, since there is no mutable reference one might be able to get to the closures environment.
Am I wrong with this conclusion? My guess is yes, otherwise there would probably be a Clippy lint for this.