fn sum(array: &[T]) -> T { let mut sum: T = 0; for i in array { sum = sum + i; } return sum; } 大概功能就是计算一个数组内的元素的和,怎么约束 T 让这段程序编译通过
阅读量:10
点赞量:0