The problem is not that function pointers are not cloned at all, but you actually have a function that is common over the lifetime &str . For example, if you replace &str with i32 , your code will compile because i32 has no lifetime. In your situation, you need to make life at the core of the function explicit:
type TypeFn<'a> = fn(s: &'a str);
Obviously, this also pops up to the structure:
This prevents the following code:
let my_var = MyStruct{field: my_fn}; let s = String::new(); (my_var.field)(&s);
Actually the problem is that this is a mistake. As shown in @MattBrubeck answer Function pointers implement Copy . Thus, you can simply implement Clone manually using the Copy impl function pointer:
impl Clone for MyStruct { fn clone(&self) -> Self { MyStruct { field: self.field, } } }
source share