Description
Let's say I've got a struct or enum containing functions (pure Rust functions, not closures, so passed by a simple pointer)
pub type Foo = fn(&int) -> ();
enum Baz {
Bar(Foo)
}
The above code works. I can pass-around instances of Baz and call the function.
Now if I wan Baz to be copy-able, which should be possible since it only contains a pointer, and add the #[deriving(Clone)]
attribute to it, I got a strange compiler error:
error: mismatched types: expected `fn(&int)` but found `fn(&int)` (expected concrete lifetime, but found bound lifetime parameter &)
test.rs:4 #[deriving(Clone)]
This worked perfectly well (including the deriving(Clone) attribute) while the function only took parameters by owned boxes or by-value. I only get this message since I added a borrowed parameter to the function. I don't see the problem here. If a function is simply passed by-pointer we should be able to copy this pointer.
I'm not sure this is the right title for this issue. Feel free to change it if it's miss chosen.