[rust-dev] Clone and enum<'a>

Igor Bukanov igor at mir2.org
Tue Jun 3 02:59:00 PDT 2014


Consider the following enum:

#[deriving(Clone)]
enum List<'a> {
    Nil,
    Next(&'a List<'a>)
}


It generates en error:

<anon>:4:10: 4:22 error: mismatched types: expected `&List<>` but
found `List<>` (expected &-ptr but found enum List)
<anon>:4     Next(&'a List<'a>)
                  ^~~~~~~~~~~~
note: in expansion of #[deriving]
<anon>:1:1: 2:5 note: expansion site
error: aborting due to previous error

Is it a bug in #[deriving] ?


More information about the Rust-dev mailing list