Function pointers and mutability

In the following code, are my only options for putting foo2 into f:
a) Change the signature of foo2
b) Wrap foo2 in another method with the correct signature

fn main() {
    let mut s = S;
    let mut f: fn(&mut S);

    f = S::foo;
    f = S::foo2;
}

struct S;

impl S {
    fn foo(&mut self) {}

    fn foo2(&self) {}
}

In reality I have more than two functions and most mutate the argument, but one particular method is degenerate and does not. I dislike having to say it does as these methods are used directly elsewhere, but I have a need to store it in the common pointer.

What issues would it cause if a function taking &self could be treated as taking &mut self for use in a function pointer?

You can do this:

    f = |s| S::foo2(s);

Anything, since nothing guaranteed. You can store some wrapper function instead though.

fn main() {
    let mut s = S;
    let mut f: fn(&mut S);

    f = S::foo;
    f = |s| s.foo2();
}

Thanks both, sorry I wasn't clear. I know that I can do that...wrapping via a closure or named method is essentially the same.

I was wondering two things really:

  1. If there were a way perhaps through type trickery of some kind to avoid the need for the nested method call. My gut feeling is the answer is "no", but it never hurts to ask. I also realize the optimizer will likely remove the nested call, but I try not to rely on that when I don't need to.

  2. What harm if any would there be in allowing a function pointer that expects a &mut self to be compatible with a function taking &self. We already can call &self functions from a mutable reference so it would really just be the flipside of that, unless I am missing something.