[solved] Expected type parameter `T`, found associated type

I have tried to implement a generic deserialization like the following:

pub trait Decodable {
    type Output;
    fn decode(value: &Encoded) -> Result<Self::Output>;
}

impl<T: Decodable> Decodable for Vec<T> {
    type Output = Vec<T>;

    fn decode(value: &Encoded) -> Result<Self::Output> {
        let mut result = Vec::with_capacity(value.len());
        for item in list {
            result.push(decode::<T>(item)?);
        }
        Ok(result) // expected type parameter `T`, found associated type
    }
}

fn decode<T: Decodable>(value: &Encoded) -> Result<T::Output> {
    // ...
}

But with the solution above I get an error at compile time:

expected type parameter T, found associated type

How do I resolve this issue?

resolved it by changing "type Output = Vec" to "type Output = Vec<T::Output>", as well as the return type

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.