pub struct Table<T> {
table: Vec<Vec<T>>
}
impl<i32> Display for Table<i32>
where i32: Display
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (index, line) in self.table.iter().enumerate() {
write!(f, "{}:\t", index+1);
let mut sum = 0i32;
for task in line {
write!(f, "{} ", task);
sum += *task;
}
write!(f, " : {}\n", sum);
}
Result::Ok(())
}
}
This code results in a confusing error message:
error[E0308]: mismatched types
--> src/table.rs:48:24
|
48 | sum += *task;
| ^^^^^ expected i32, found type parameter
|
= note: expected type `i32` (i32)
= note: found type `i32` (type parameter)
And I don't know what to do.