How do I manually implement "clone()" for Structs/Enums with lifetime
parameters (e.g. for struct below)? I could not even work out how to get
the compiler to automatically implement "clone()". That is :
---------------------------------------------------
struct Cls<'a,T> {
x:&'a T
}
fn main(){}
---------------------------------------------------
compiles fine, but as soon as I try to get the compiler to
automatically generate "clone()" via :
---------------------------------------------------
#[deriving(Clone)]
struct Cls<'a,T> {
x:&'a T
}
fn main(){}
---------------------------------------------------
I get the following error :
test1.rs:3:5: 3:12 error: mismatched types: expected `&<generic #3>` but
found `T` (expected &-ptr but found type parameter)
test1.rs:3 x:&'a T
^~~~~~~
note: in expansion of #[deriving]
test1.rs:1:1: 2:7 note: expansion site
error: aborting due to previous error
I was also trying to specify that T itself implemented the Clone trait, but
couldn't work out how to do that.
Thanks
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev