I try to develop a function that take a Encodable parameter but I have the error wrong number of type arguments: expected 1 but found 0

pub fn memory_encode(to_encode_object: &serialize::Encodable) -> @mut MemWriter {
   //Serialize the object in a string using a writer
    let m = @mut MemWriter::new();
    let mut encoder = Encoder(m as @mut Writer);
    to_encode_object.encode(&mut encoder);
    m
}

The encodable trait is :
pub trait Encodable<S:Encoder> {
    fn encode(&self, s: &mut S);
}

I try this definition
memory_encode<T:serialize::Encodable<Encoder>>(to_encode_object: &T) -> @mut MemWriter

But I can't use the method with a struct that implement Encodable. The error : mismatched types: expected `&<V31>` but found ..

I have another question :
I would like to return a MemWriter and not a @mut MemWriter . I didn't find a way to convert the @mut to ~

Philippe Delrieu
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to