This commit is contained in:
e2hang
2025-10-05 23:51:24 +08:00
parent 1f9543c16c
commit 23f17bfc2c
113 changed files with 1236 additions and 0 deletions

18
Common-Use/vec.rs Normal file
View File

@@ -0,0 +1,18 @@
fn sum(list:&Vec<i64>) -> i64 {
let mut total = 0;
for i in list {
total += i;
}
total
}
fn main(){
let mut v: Vec<i64> = Vec::new();
v.push(1);
v.push(2);
v.push(3);
for i in &v {
println!("{}", i);
}
println!("Sum: {}", sum(&v));
}