Invoking function stored in a struct using Rust
There are two distinct applications of mutability in Rust:


Bindings (variables) can be mutable or immutable.
Borrows (references) can be mutable or immutable.


Here, you're not using any borrows, so we're only concerned with bindings.

Note that values are not intrinsically mutable or immutable. Therefore, when you move a value from one binding to another, you can change the mutability. The methods invoke and get_invocation take ownership of the Cmd, therefore they can decide to declare self as mutable, even if the original value is not declared as mutable. For example, this is valid:

impl&lt;T: FnMut()&gt; Cmd&lt;T&gt; {
    pub fn invoke(mut self) {
        (self.invocation)();
    }
}

fn help() {
    println!("not implemented yet :)");
}

fn main() {
    let cmd = Cmd::new("help", help);
    cmd.invoke();
}


If you were to take self by mutable reference, rather than by value, then the original variable would indeed need to be declared as mutable. You could not invoke the function with only an immutable reference, because FnMut closures can't be invoked from an immutable borrow. If that's a problem, switch to Fn instead.

impl&lt;T: FnMut()&gt; Cmd&lt;T&gt; {
    pub fn new(name: &amp;str, invocation: T) -&gt; Cmd&lt;T&gt; {
        Cmd {
            name: String::from(name),
            invocation,
        }
    }

    pub fn invoke(&amp;mut self) {
        (self.invocation)();
    }

    fn get_invocation(&amp;mut self) -&gt; &amp;mut T {
        &amp;mut self.invocation
    }
}

fn help() {
    println!("not implemented yet :)");
}

fn main() {
    let mut cmd = Cmd::new("help", help);
    cmd.invoke();
}