rust - Trouble with Encodable Trait Bounds on Enums and Structs -
taking rust test drive. fun far, i'm uncertain how set trait bounds in instance useful. failed find implementation of trait serialize::serialize::encodable,std::io::ioerror> t it seems me need set bound on enumeration list<t: encodable> . however, compiler gets bit upset when try this. error: trait bounds not allowed in enumeration definitions so assumed have put bounds on implementation impl<t:encodable> , got this... error: wrong number of type arguments: expected 2 found 0 if that's case, how in rust? extern crate serialize; use serialize::{ json, encodable }; #[deriving(decodable, encodable)] pub enum list<t> { node(t, box<list<t>>), nil } impl<t> list<t> { fn to_json(&self) -> string { json::encoder::str_encode(self) } } seems work fine when work don't try encapsulate encoding, since knows int encodable... let mut list: list<int> = nil; ... let encoded